This technique is useful while using it in web server. if you use the name of the web site (eg:google.com) instead of "localhost" you cannot establish a connection. MySQL shows an error message. MySQL will not allow to connect from another server unless otherwise "remote management" is enabled.
This code is linux specific.
In windows use "double quotes" insted of 'single quotes'
$link = mysql_connect('localhost', 'username_of_the_webspace', 'password_for_the_webspace');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully ';
mysql_close($link);
No comments:
Post a Comment