作者:guanchunlei | 来源:互联网 | 2023-05-18 12:32
mysqli打开与php版本有关,尤其是php7以后不支持mysqli链接,只有pdo方式$DB_HOSTlocalhost;$DB_NAMEhello;$DB_USER
mysqli 打开与php版本有关,尤其是php7以后不支持mysqli链接,只有pdo方式
$DB_HOST="localhost";
$DB_NAME="hello";
$DB_USER="root";
$DB_PASS="root";
echo $DB_HOST.$DB_NAME.$DB_USER.$DB_PASS;//="root";
if(!mysql_pconnect($DB_HOST,$DB_USER,$DB_PASS))
die('Could not connect: ' . mysql_error());
else echo "db opened ok";
// use db
mysql_query("set names utf8");
if(!mysql_select_db($DB_NAME))
die('Can\'t use foo : ' . mysql_error());
else echo "dbname opened ok";
//sychronize php and mysql server
date_default_timezone_set("PRC");
mysql_query("SET time_zOne='+8:00'");