PHP头条
热点:

麻烦各路PHP高手回答一下!该怎么解决


麻烦各路PHP高手回答一下!
$serverLink = @mysql_connect("localhost","root","")or die("连接服务器失败!程序中断执行!");
mysql_query("set names'gbk'");
$dbLink = @mysql_select_db("student",$serverLink)or die("当前连接服务器失败!程序中断执行!");
if($dbLink){
echo"选择student数据库为当前数据库!";
}
$close = @mysql_close($serverLink);
?>
当我运行这个程序时,页面显示的总是("当前连接服务器失败!程序中断执行!");而我想页面显示"选择student数据库为当前数据库!";
该怎么办?


------解决方案--------------------
$serverLink = mysql_connect("localhost","root","") or die(mysql_error());
mysql_query("set names'gbk'");
$dbLink = mysql_select_db("student",$serverLink) or die(mysql_error());

这样程序就会告诉你错在哪了。

------解决方案--------------------
你上个问题问的比这个具体。我看你说的是把student作为数据表建立的 ,那么就意味着根本不存在student数据库。所以先CREATe DATABASE student吧。请登录PHPMYADMIN查看下详细内容吧。

如果真的是有数据库student存在,去掉@符号,让系统报详细sql错误吧。

www.phpzy.comtrue/phprm/51870.htmlTechArticle麻烦各路PHP高手回答一下!该怎么解决 麻烦各路PHP高手回答一下! $serverLink = @mysql_connect("localhost","root","")or die("连接服务器失败!程序中断执行!"); mysql_query("set names'gbk'"); $dbLink = @m...

相关文章

PHP之友评论

今天推荐