Re: mysql_select_db() problem
| From: | Lars Torben Wilson | Date: | Sat, 09 Feb 2002 22:29:00 +0000 |
| Subject: | Re: mysql_select_db() problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84139@lists.php.net to get a copy of this message | ||
On Sat, 2002-02-09 at 12:24, Nick Wilson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi all,
> I just can't see what could possibly be wrong with my php here:
>
> $sel_db=mysql_select_db("mydb") or die
> ("could not get the bugger");
> exit;
>
> I can 'USE mydb' just fine from the command line so what's the problem?
> (returns the die statement)
>
> Much thanks..
> - --
>
> Nick Wilson
I take it that the connection worked fine? (Yeah, dumb question, but you
never know.)
What do you get if you use error checking?
if (!$dbh = mysql_connect(. . .)) {
echo "Could not connect; reason was " . mysql_error() . "\n";
return false;
}
if (!$sel_db = mysql_select_db('mydb', $dbh)) {
echo "Could not select database '$sel_db'; reason was " .
mysql_error() . "\n";
return false;
}
i.e. what do you get if you use mysql_error() after this fails?
Torben
--
Torben Wilson <torben@php.net>
http://www.thebuttlesschaps.com
http://www.hybrid17.com
http://www.inflatableeye.com
+1.604.709.0506