mysql_connect() Help

From: Date: Sat, 08 Mar 2008 19:36:16 +0000
Subject: mysql_connect() Help
Groups: php.db 
Request: Send a blank email to php-db+get-44721@lists.php.net to get a copy of this message
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

« previous php.db (#44721) next »