php 连接mysql失败

hinswhale 2012-04-28 10:07:36
复制以下代码粘贴至conn_mysql.php文件,把“你的密码”改成你的mysql密码
<?php
$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.
这是怎么回事,本人是菜鸟,求大侠们知道。
...全文
1013 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
hinswhale 2012-05-02
  • 打赏
  • 举报
回复
<?php
phpinfo();
?>
正常
黄袍披身 2012-04-29
  • 打赏
  • 举报
回复
确认文件名和文件位置是否正确
luzhaodeng 2012-04-29
  • 打赏
  • 举报
回复
是不是没有启动服务器?
wskbuaa1984 2012-04-29
  • 打赏
  • 举报
回复
http://wenku.baidu.com/view/53a8503383c4bb4cf7ecd102.html
按照这个一步一步配置就可以了。
积累是金 2012-04-29
  • 打赏
  • 举报
回复
检查你的php环境和, 先检查你的WEB服务器环境吧 如果是Apache的话 检查配置是否正常, 监测方法:尝试输出 <? phpinfo();?>
liuhao 2012-04-29
  • 打赏
  • 举报
回复
放在网站目录中了吗?
lyccqy 2012-04-29
  • 打赏
  • 举报
回复
访问路径不对啊 !
黄袍披身 2012-04-29
  • 打赏
  • 举报
回复
根目录新建个文件

<?php
phpinfo();
?>

然后看看是否正常
hinswhale 2012-04-29
  • 打赏
  • 举报
回复
[Sun Apr 29 13:44:07 2012] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Apr 29 13:44:07 2012] [notice] Apache/2.2.22 (Win32) PHP/5.2.17 configured -- resuming normal operations
[Sun Apr 29 13:44:07 2012] [notice] Server built: Jan 28 2012 11:16:39
[Sun Apr 29 13:44:07 2012] [notice] Parent: Created child process 7676
[Sun Apr 29 13:44:07 2012] [notice] Child 7676: Child process is running
[Sun Apr 29 13:44:07 2012] [notice] Child 7676: Acquired the start mutex.
[Sun Apr 29 13:44:07 2012] [notice] Child 7676: Starting 64 worker threads.
[Sun Apr 29 13:44:07 2012] [notice] Child 7676: Starting thread to listen on port 80.
[Sun Apr 29 13:44:12 2012] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Apr 29 13:44:12 2012] [notice] Apache/2.2.22 (Win32) PHP/5.2.17 configured -- resuming normal operations
[Sun Apr 29 13:44:12 2012] [notice] Server built: Jan 28 2012 11:16:39
[Sun Apr 29 13:44:12 2012] [notice] Parent: Created child process 5868
[Sun Apr 29 13:44:12 2012] [notice] Child 5868: Child process is running
[Sun Apr 29 13:44:12 2012] [notice] Child 5868: Acquired the start mutex.
[Sun Apr 29 13:44:12 2012] [notice] Child 5868: Starting 64 worker threads.
[Sun Apr 29 13:44:12 2012] [notice] Child 5868: Starting thread to listen on port 80.
[Sun Apr 29 13:44:22 2012] [notice] Parent: child process exited with status 255 -- Restarting.
[Sun Apr 29 13:44:23 2012] [notice] Apache/2.2.22 (Win32) PHP/5.2.17 configured -- resuming normal operations
[Sun Apr 29 13:44:23 2012] [notice] Server built: Jan 28 2012 11:16:39
[Sun Apr 29 13:44:23 2012] [notice] Parent: Created child process 7028
[Sun Apr 29 13:44:23 2012] [notice] Child 7028: Child process is running
[Sun Apr 29 13:44:23 2012] [notice] Child 7028: Acquired the start mutex.
[Sun Apr 29 13:44:23 2012] [notice] Child 7028: Starting 64 worker threads.
[Sun Apr 29 13:44:23 2012] [notice] Child 7028: Starting thread to listen on port 80.
这是error.log内容,在浏览器里输入:http://127.0.0.1/conn_mysql.php后网页还是打不开
黄袍披身 2012-04-29
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 的回复:]

哪里不行。你至少要给出错误信息吧。
[/Quote]

搞不好 php都还没支持...哈哈
一起混吧 2012-04-29
  • 打赏
  • 举报
回复
哪里不行。你至少要给出错误信息吧。
hinswhale 2012-04-29
  • 打赏
  • 举报
回复
Apache配置是否正常,放在根目录还是不行呀。什么情况?
一起混吧 2012-04-28
  • 打赏
  • 举报
回复
需要放在根目录下。
coder 2012-04-28
  • 打赏
  • 举报
回复
访问的路径不对。看看conn_mysql.php放在什么地方了
改一下昵称 2012-04-28
  • 打赏
  • 举报
回复
not found 是你这个php页面没找到,和程序连接数据库没关系,你首先要弄清除
检查网站根目录下是否有 conn_mysql.php文件

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧