oops, i forgot a @ for mysql_connect() but oh
well, you get the point :)
Regards,
Philip Olson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> The following code always returns the "Couldn't select
> database" error.
> $db_name="mydb";
> $table_name="my_table";
> $connection = @mysql_connect("localhost", "user", "password") or die
> ("Couldn't connect.");
> $db = @mysql_select_db($db_name) or die ("Couldn't select database");
> ?>
I use the following code for connection and selecting databases:
$link =
mysql_pconnect("localhost",$_SESSION['dbauser'],$_SESSION['dbapassword'])
or die("Could not connect");
print "Connected successfully";
mysql_select_db("stamps") or die("Could not select database");
This wo
Do some error checking. You're turning off all the errors produced by the mysql
statements, so how
are you supposed to know what's wrong?
You could also try:
$db = mysql_select_db($db_name) or exit(mysql_error());
I'm not sure if mysql_error works for selecting the db, but it couldn't hurt to
> > What do you get if you use error checking?
>
> Well, that seems to be it, I'm getting 'Access deneid to user
> '@localhost'.
>
> I'm talking to a guy on the mysql list, apparently it is a
> phenomememememememmemonmmm that when you GRANT ALL using wildcards it
> tends to grant all on * exce
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
* and then Lars Torben Wilson declared
> I take it that the connection worked fine? (Yeah, dumb question, but you
> never know.)
Yeah, all is well as far as connections concerned.
> What do you get if you use error checking?
Well, that seems t
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
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
* and then Jeff Sheltren declared
> It may be having a problem because you are not specifying which
> connection to use.
>
> perhaps try something like this:
>
> if(!$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd"))
> die("An Error
It may be having a problem because you are not specifying which connection
to use.
perhaps try something like this:
if(!$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd"))
die("An Error Occured. Unable to connect to the database.");
if(!@mysql_select_db("$dbname",$db))
die("An Er
9 matches
Mail list logo