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

WBOY
Release: 2016-06-13 10:25:54
Original
802 people have browsed it

麻烦各路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存在,[email protected],让系统报详细sql错误吧。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!