Hi,
I am trying to make a connection to the MySQL database from PHP but it
seems like I am missing a step or something and hence cannot connect
to the database. I have tried everything but I can't figure out why.
Please suggest/help (I am a beginner in PHP/MySQL/Apache).
I am using MySQL 5.0.51a-community-nt on my Windows XP machine. PHP
version used is 5.2 and Apache version is 2.2.
Code Snippet:
$hostname="localhost";
$mysql_login="admin";
$mysql_password="admin";
//$database="sampleapp";
echo "Print this..."; // THIS MESSAGE IS PRINTED
$link = mysql_connect($hostname,$mysql_login,$mysql_password);
echo " After connecting to the database..."; // THIS DOES NOT PRINT
if (!$link) {
die (mysql_error()); // NOR THIS ONE
}
$dbname = 'sampleapp';
mysql_select_db($dbname);
echo $link;
if (!$link) {
die('Could not connect: ' . mysql_error());
echo "Some problem here....";
}
//echo 'Connected successfully';
mysql_close($link);
?>
Any help is appreciated.
Thanks,
Manysh
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php