2011-02-07 68 views
0

可能重复Recieving错误:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result即使脚本功能

我收到以下错误

警告:请求mysql_query() [功能。 mysql-query]:用户'anticub1'@'localhost'的访问被拒绝 (使用 密码:否)

警告:请求mysql_query() [function.mysql-查询]:链接到 服务器不能建立

警告:mysql_fetch_assoc():提供参数不是有效的MySQL结果资源

当我提交表单都进入数据库,所以我不知道为什么我收到这个错误...

<?php 
$submit=$_POST['submit']; 
$text=$_POST['text']; 

if ($submit) { 
    $connect = mysql_connect("localhost","anticub1_shout","root12") 
    or die("could not connect"); 
    mysql_select_db("anticub1_shoutbox") or die("could not find the db"); 

    mysql_query("INSERT INTO comments VALUES ('','$text')");} 

    $query = mysql_query("SELECT * FROM comments"); 

    while ($row = mysql_fetch_assoc($query)) { 
    $post = $row["posts"]; 
    echo "$post"."<br>"; 
    } 
?> 
+1

检查DB是相同的服务器和用户名,密码的正确 – 2011-02-07 14:11:43

+0

是一切是正确的,当我提出我看到它在数据库中的表单信息 – 2011-02-07 14:14:24

回答

0

警告:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'anticub1'@'localhost' (using password: NO) 

你的榜样脚本生成!因为你在那里提供密码和其他用户名。

$connect = mysql_connect("localhost","anticub1_shout","root12") 

结论:您正在搜索错误的地方。搜索低谷所有的代码为mysql_connect("localhost","anticub1")