Home  >  Article  >  Backend Development  >  php 联接mysql失败

php 联接mysql失败

WBOY
WBOYOriginal
2016-06-13 13:21:45993browse

php 连接mysql失败
复制以下代码粘贴至conn_mysql.php文件,把“你的密码”改成你的mysql密码
$connection = mysql_connect ("localhost","root","你的密码");
mysql_select_db ("mysql");
if($connection){
echo "<script>alert('数据库连接正常');</script>";
}
else{
echo "<script>alert('数据库连接失败,请检mysqle服务是否启动');</script>";
}
?>

在浏览器里输入:http://127.0.0.1/conn_mysql.php后失败
显示:Not Found

The requested URL /conn_mysql.php was not found on this server.
这是怎么回事,本人是菜鸟,求大侠们知道。


------解决方案--------------------
访问的路径不对。看看conn_mysql.php放在什么地方了
------解决方案--------------------
需要放在根目录下。
------解决方案--------------------
放在网站目录中了吗?
------解决方案--------------------
根目录新建个文件

phpinfo();
?>

然后看看是否正常

Statement:
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