Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

MySQL: Changing databases in the middle of a script

0

36 views

I've never had to do this before, so really I just want to check and see if I'm approaching this the correct way.

I need to switch databases in the middle of a PHP script, and I'm not sure if there are any security issues, or memory issues, or etc...

So I have my connection code at the top of my page.

And in the middle I do the following:

mysql_select_db("new_db") or die(mysql_error());
$query = mysql_query("SELECT * FROM new_db table ORDER BY name ASC");
// Rest of relevant code

Now is there a way to kill this connection afterwards, or do I need to switch back below this part?

asked June 24, 2011 11:18 am CDT
posted via StackOverflow

1 Answer

0
 

Just do a $query = mysql_query("SELECT * FROM new_db.table ORDER BY name ASC");

without having to do a mysql_select_db if it's only for one query

answered June 24, 2011 11:23 am CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions