accessing mysql using different server to which db connection data is located
I'm trying to include a file with all my db connection info (hostname password username).
this is what i have so far:
include ('http://site.com/config35sdf322e54353452d/wp2154654315634652132513546541564.php');
mysql_connect($hostname,$username,$password);
@mysql_select_db($dbname) or die( "Unable to select database");
include ('../refference.php');
$select = mysql_query("SELECT my_field FROM $usertable WHERE ".
"GDI_Username = '$sponsor_GDI_id' AND Unique_id = '$sponsor_refference'");
while($check = mysql_fetch_array($select)) {
$sponsor_email = $check["email"];
$sponsor = $check["GDI_Username"];
$sponsor_first_nme 开发者_JS百科= $check["First_Name"];
$sponsor_second_nme = $check["Last_name"];
$sponsor_domain = $check["GDI_Domain"];
$unq_id = $check["Unique_id"];
}
$sponsor_name = "$sponsor_first_nme $sponsor_second_nme";
echo "$sponsor $hostname" ?>
I get an error saying it cant select db ("unable to select database")
after some investigating (with the echo statement at the end of the code), it seems to be having issues including the .php file on a different server error code:include ('http://site.com/config35sdf322e54353452d/wp2154654315634652132513546541564.php');
Any clues?
Thanks
You can include PHP files from a remote server by enabling the allow_url_include
function in the php.ini file.
Or you can enable it at runtime by adding this to the top of your script
ini_set('allow_url_include', 1);
However, this can cause security issues (for instance, it allows an attacker to include a remote file, such a shell)
You can't include your php file from different domain
either
mysql_connect();
fails but you have no error handler there
mysql_connect($hostname,$username,$password);
$hostname should be your remote host like www.remotehost.com or 192.168.0.100
Moreover, your remote host must be configured to accessed remotely
and as genesis said, "You can't include your php file from different domain"
精彩评论