View Full Version : php and mysql
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
02-08-2006, 09:25 PM
No, you can have more than one connection at once.
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.
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.
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
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:
02-09-2006, 12:48 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.