Re: Problems connecting to a MySQL database
| From: | Jeff Bluemel | Date: | Thu, 12 Dec 2002 19:18:45 +0000 |
| Subject: | Re: Problems connecting to a MySQL database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128050@lists.php.net to get a copy of this message | ||
have you tried connected to the mysql database from a prompt before using
php???
"Eric" <eric.linux@t-online.de> wrote in message
news:20021212182349.96157.qmail@pb1.pair.com...
> 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