Friends I have a big problem. I have several database connections. I have to use those connections dynamically in a mysql_query(). For example,
$db1=mysql_connect('port','username','password') or die("cannot connect to the database");
@mysql_select_db('db1') or die("Unable to select Database");
$db2=mysql_connect('port','username','password') or die("cannot connect to the database");
@mysql_select_db('db2') or die("Unable to select Database");
which connection to use is defined from a switch case.
switch(type){
case "1":
$link="$db1";
break;
case "2":
$link="$db2";
break;
}
my mysql_query is like this.
mysql_query("DELETE FROM table1 WHERE id='2'",$link);
unfortunately it's not working it says supplied argument is not a valid MySQL-Link resource
I have tried following also but no luck
mysql_query("DELETE FROM table1 WHERE id='2'".','.$link);
How can i do this? Any idea ??
$link="$db1";and$link="$db2";