Re: database hell
| From: | Gibbs | Date: | Thu, 12 Jul 2012 11:34:06 +0000 |
| Subject: | Re: database hell | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-318435@lists.php.net to get a copy of this message | ||
On 12/07/12 12:29, Nick Edwards wrote:
Hi
We have a program that manages users, throughout all database calls
created as:
$connect = mysql_connect($db_host--other variables);
mysql_query("Delete from clients where id=$User");
All this works good, but, we need, in the delete function to delete
from another database
$connmy=mysql_connect("host","user","pass");
mysql_select_db("vsq",$connmy);
mysql_query("DELETE from userprefs where clientr='$User'");
$mysql_close($connmy);
this fails, unless we use a mysql_close prior to it, and then
reconnect to original database after we run this delete, how can we
get around this without closing and reopening?
We have a perl script doing similar for manual runs, and it works
well knowing that $connmy is not $connect, I'm sure there is a simple
way to tell php but I'm darned if I can see it.
Thanks
Niki
You need to make a new link. So you would add TRUE to the end of the second connection.
$connmy=mysql_connect("host","user","pass", TRUE);
http://php.net/manual/en/function.mysql-connect.php
Gibbs