...

View Full Version : php and mysql



jeromepelletier
02-08-2006, 08:58 PM
If i start a mydql connection and store some data as variables, can i open a new connection ? WIll the first connection close or how do i do dhtis

marek_mar
02-08-2006, 09:25 PM
No, you can have more than one connection at once.

raf
02-08-2006, 10:40 PM
if you use a standard textbook mysql_connect() without the new_link parameter set to True, then no new connection will be openend on your second (and following) mysql_connect() calls.

this is also very sensible of php, because why would you need a second connection? during the scriptexecution, php will keep using the same connection and then close it automatically when the script is finished. this way, you avoid a lott of overhead because you don't need to keep opening and closing connections.

Element
02-08-2006, 11:44 PM
Why would you need more then one connection, can't you just use one and re-select a database? Never tried it so I'm not sure about that one lol.

jeromepelletier
02-09-2006, 12:09 AM
because i have 2 games, want 1 to relate to the other through a contest, so, i need to acces my toher databse to do so

Kid Charming
02-09-2006, 12:20 AM
As long as both db's are on the same server, you can use the same connection and switch between them with mysql_select_db().

You don't even have to do this, though, as you can determine the db you're using directly in the query:



SELECT
foo
FROM
databasename.tablename

jeromepelletier
02-09-2006, 12:48 AM
:) thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum