为什么它报错???Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\loading\index.php on line 12源码是:
 include_once("config.php");
 $username=str_replace(" ","",$_POST[username]);
 $str="select * from 1 where username = '$username'";
 $result=mysql_query($str);
 $i=is_array($row=mysql_fetch_array($result));
 $j=$i ? md5($_POST[password].ALL_PS) == $row[password] : FALSE;
 if($j){
  echo "登陆成功";
 }else{
  echo "登陆失败,用户名或密码错误";
 }
?>
    <form name="myform" method="post" action="index.php">
      <table width="100%" height="95" align="center">
         <tr>
           <td align="right">用户名</td>
           <td><input type="text" name="username" size="15" /></td>
         </tr>
         <tr>
           <td align="right">密&nbsp;&nbsp;码</td>
           <td><input type="password" name="pwd" size="15" /></td>
         </tr>
         <tr>
           <td>&nbsp;</td>
           <td><input type="submit" name="submit" value="登陆" />
               <input type="reset" name="reset" value="重置" /></td>
         </tr>
      </table>
      </form>

解决方案 »

  1.   

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\loading\index.php on line 12$result=mysql_query($str);句有问题, 
    确定表 from 1 ,然后确定数据连接正常,
    echo $str.'<br>';echo $result;
    打印出来看看,调试一下程序就解决了,跟踪一下,
      

  2.   

    select * from 1 where username = '$username'
    这句错了
      

  3.   

    select * from 1 where username = '$username'
    改成:
    select * from 数据库.1 where username = '$username'
      

  4.   

    用echo 输出$str检查一下 sql语句
    最好是将 $result 判断一下
      

  5.   

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\loading\index.php on line 12这个错误类型说明sql语句执行错误,一般来说是SQL语句在拼接的过程中出现了错误,"select * from 1 where username = '$username'";检查一下这句里的表名是否有问题此外把这句SQL输出一下,看看在数据库里能运行不
      

  6.   

        $result不是有效数据啦,先判断$result是否有返回。
    if($result)
    {
       ......
    }
      

  7.   

    '$username'这个是不是打成了中文的‘’而是''
      

  8.   

    $str="select * from 1 where username = '$username'";
    改成:
    $str="select * from `1` where `username` = '".$username."'";
    即可。
      

  9.   

    1、表名是1吗?
    2、查询为空的话,就不要执行mysql_fetch_array了。用个if语句判断下,这是个好习惯。
      

  10.   

    select 1  from tablename where username=".." and userpwd=".."