+ -
当前位置:首页 → 问答吧 → php include 出错

php include 出错

时间:2010-10-11

来源:互联网

编写了一个测试连接sql的登录文件,代码如下:
<style type="text/css">
<!--
.logintable {
    font-size: 12px;
    text-align: center;
}
-->
</style>

<?php


   include("../linksql.php");


  
   if($_POST[login])
   {
      $sql="select * from users ";
      $query=mysql_query($sql);
      $row=mysql_fetch_array($query);
      if(empty ($_POST[txtusername])){
       echo "不为空";
      
      }else echo "username:$row[username]";
      
   }

?>

    
<form id="form1" name="form1" method="post" action="">
  <table width="698" border="0" class="logintable">
    <tr>
      <td>用户名:
        <input type="text" name="txtusername" /></td>
    </tr>
    <tr>
      <td>密 码:  
        <input type="password" name="txtpassword" /></td>
    </tr>
    <tr>
    
      <td> <div align="center">
        <input type="submit" name="login" value="登录" />
      </div></td>
    
    </tr>
    <tr>
      <td> </td>
    </tr>
  </table>
</form>
运行出错:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\mydocs\users\login.php on line 21
连接文件linksql.php代码没有错,不使用include 或require就不会有错。请各位帮我检查下是什么原因。


作者: zqmlzxphp   发布时间: 2010-10-11

include的包没有包涵进去。、

作者: ahlijunjie   发布时间: 2010-10-11