Forum Moderators: coopster
regards
<?
function db_connect()
{
$result = @mysql_pconnect("host", "username", "pw");
if (!$result)
return false;
if (!@mysql_select_db("DB a"))
return false;
return $result;
}
function get_writer_record($username)
{
$conn = db_connect();
$sql = "select * from manager where username = '$username'";
$result = mysql_query($sql, $conn);
return(mysql_fetch_array($result));
}
function get_new_content_record($new_content)
{
$conn = db_connect();
$sql = "select * from corp where id = '$new_content'";
$result = mysql_query($sql, $conn);
return(mysql_fetch_array($result));
}
?>
function db_connectb()
{
$result = @mysql_pconnect("host", "username", "pw");
if (!$result)
return false;
if (!@mysql_select_db("DB b"))
return false;
return $result;
}
or edit the existing one to take an argument
function db_connect($database)
{
$result = @mysql_pconnect("host", "username", "pw");
if (!$result)
return false;
if (!@mysql_select_db("DB $database"))
return false;
return $result;
}
//call with:
$conn=db_connect("a");
//or with:
$conn=db_connect("b");
or edit your sql that needs the 2nd database to refer to it:
$sql = "select * from `DB b.corp` where id = '$new_content'";
Vince