Re: mysql_query and mysql_db_query

From: Date: Fri, 08 Sep 2000 20:51:46 +0000
Subject: Re: mysql_query and mysql_db_query
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-2752@lists.php.net to get a copy of this message
On Fri, 8 Sep 2000, Kevin Xin Lin wrote: > Could anyone give me a brief description of the difference between these > 2 functions? For mysql_query(), how do I know which DB my query is > running against, namely, what's my default DB when using mysql_query()? > > Thanks. Well, the manual seems to be fairly good about this. mysql_query() sends a query to the database which was selected beforehand with the mysql_connect() function. IOW, you must do a mysql_connect() or mysql_pconnect() function before doing a mysql_query. You specify the result of the mysql_connect() as one of the parameters to mysql_query(). That's how it knows which db to use. If you don't specify the second parameter to mysql_query(), it uses the LAST db that you specified in a mysql_connect(). I guess that it will fail if you have never issued a mysql_connect() call. mysql_db_query() does not require the mysql_connect() to be done first since it specifies the db to use in the call itself. John

« previous php.db (#2752) next »