Problems connecting to a MySQL database

From: Date: Thu, 12 Dec 2002 18:37:49 +0000
Subject: Problems connecting to a MySQL database
Groups: php.general 
Request: Send a blank email to php-general+get-128047@lists.php.net to get a copy of this message
Greetings! I have a script which attempts to connect to the database in three different segments of code. I'm using this code to connect to the database: $db = mysql_connect("the_host", "the_user", $cfg['Servers'][0]['password']); . . . . mysql_close($db); The first time I connect ok, retrieve all of the rows from a table, and display portions of a column. A user then clicks on a button to retrieve more detailed information from the same table in the database: $db = mysql_connect("the_host", "the_user", $cfg['Servers'][0]['password']); This bombs with: Warning: Undefined offset: 0 in (directory stuff)/www/cgi-php4/my_script.php on line 228 Warning: Access denied for user: 'the_user' (Using password: NO) in (directory stuff)/www/cgi-php4/my_script.php on line 228 Warning: MySQL Connection Failed: Access denied for user: 'the_user' (Using password: NO) in (directory stuff)/www/cgi-php4/my_script.php on line 228 Error: Could not connect to the database. Now, if I change the index to match the exact number of rows in the table, it's successfully accessed: $db = mysql_connect("the_host", "the_user", $cfg['Servers'][4]['password']); it works fine. But I don't think this is right. Any ideas as to why this is happening? Thanks much! Eric

« previous php.general (#128047) next »