Categories
CS

SAE 连接MySQL数据库


//************connect to the database server***********************
$con=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
if (!$con){
die('Could not connect: ' . mysql_error());
$contentStr=sprintf($textReply,"无法连接到数据库服务器");
return $contentStr;
}else {
echo 'Database server is connected successfully!
';
mysql_query("set names utf8");//插入中文和中文
}
if ( !mysql_select_db(SAE_MYSQL_DB, $con) ){
die("不能选择数据库".mysql_error());
$contentStr=sprintf($textReply,"不能选择数据库");
return $contentStr;
}

Leave a Reply

Your email address will not be published. Required fields are marked *