mysql_query - does link identifier need to be specified?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

mysql_query - does link identifier need to be specified?

Post by Jean-Yves »

Hi,

Having read the manual, I'm pretty sure that the answer is no, but could someone confirm that given the connection code below, I don't need to specify a link identifier in subsequent mysql_query calls, even in a multi-user environment. I just want to be sure that when the manual says:
If link_identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if mysql_connect() was called with no arguments, and use it.

Code: Select all

$link = mysql_connect("localhost", "xxxxxx", "xxxxxx") or die("Unable to establish connection<br/>");

    mysql_select_db("xxxxxx") or die("mySQL: Unable to select database<br/>");
So, if person A creates a link to the database and is assigned a handle, and person B also connects, A's handle won't be confused with B's.

Many thanks
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yeah you generally don't have to bother specifying the connection handle. The only time you might want to is if you have say 2 connections to different databases.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Cheers Mark, that makes my life a lot easier :)
Post Reply