Hi there,
Currently i am writing a script which needed to connect database in another server, i used the normal function like below:
<?
$user = "abc";
$password = "abc456";
$database = "foo";
$host = "bar";
$link = mysql_pconnect($host, $user, $password);
$query = "SELECT * FROM content WHERE cnt_id=1;";
if ($result = mysql_db_query($database, $query))
{
if ($content = mysql_fetch_array($result)) {
$column = "\n";
$column .= "<head>\n";
$column .= "<title>".stripslashes(strip_tags($content['cnt_title']))."</title>\n";
$column .= "<meta name=\"description\" content=\"".stripslashes(strip_tags($content['cnt_desc']))."\">\n";
$column .= "</head>\n";
$column .= "<body>\n".stripslashes($content['cnt_body1'])."\n</body>\n";
$column .= "";
}
echo $column;
}
?>
But, this script failed and it returned warning like 'link cannot be established' and etc.
My question is: is it the right way to use the function above to connect to the database in remote server? Please give me some guideline.
Currently i am writing a script which needed to connect database in another server, i used the normal function like below:
<?
$user = "abc";
$password = "abc456";
$database = "foo";
$host = "bar";
$link = mysql_pconnect($host, $user, $password);
$query = "SELECT * FROM content WHERE cnt_id=1;";
if ($result = mysql_db_query($database, $query))
{
if ($content = mysql_fetch_array($result)) {
$column = "\n";
$column .= "<head>\n";
$column .= "<title>".stripslashes(strip_tags($content['cnt_title']))."</title>\n";
$column .= "<meta name=\"description\" content=\"".stripslashes(strip_tags($content['cnt_desc']))."\">\n";
$column .= "</head>\n";
$column .= "<body>\n".stripslashes($content['cnt_body1'])."\n</body>\n";
$column .= "";
}
echo $column;
}
?>
But, this script failed and it returned warning like 'link cannot be established' and etc.
My question is: is it the right way to use the function above to connect to the database in remote server? Please give me some guideline.