代码如下,不知道为什么登录后什么都没有显示出来啊!<html>
<head>
<title>用户</title>
</head><body>
<?php
  // create short variable names
  $name=$_POST['name'];
  $passwd=$_POST['passwd'];
  $name= trim($name);  $passwd= trim($passwd);  if (!$name || !$passwd)
  {
     echo 'You have not entered search details.  Please go back and try again.';
     exit;
  }
  //echo '123';  
  if (!get_magic_quotes_gpc())
  {
    $name = addslashes($name);
    $passwd = addslashes($passwd);
  }
  //echo '123';
  @ $db = mysqli_connect('localhost', 'root', '123', 'ruanjiangongcheng');
 
  if (!mysqli_connect_errno()) 
  {
     echo 'Error: Could not connect to database.  Please try again later.';
     exit;
  }  
  $query1 = "select * from user ";
  $result = $db->query($query1);
  
  $num_results = $result->num_rows;  echo '<p>Number of books found: '.$num_results.'</p>';  
  
?></body>
</html>

解决方案 »

  1.   

    先把错误打开 error_reporting(E_ALL);看报啥错。。
      

  2.   

    补充一下,也就是说页面完全空白,曾经在语句 @ $db = mysqli_connect('localhost', 'root', '123', 'ruanjiangongcheng');
    前后输出一些字,发现应该是这一句开始出问题,但就是不知道出什么问题,求大神解答啊
      

  3.   

    请问要怎样打开error_reporting(E_ALL);
      

  4.   

    form表单如下:
    <html>
    <head>
    <title>职工工作量在线计算统计网</title>
    <head>
    <body bgcolor="lightblue">
    <p align="center">
    <font color="blue" size="20">
    用户登录</font>
    <hr width="100%" size="5" noshade>
    <form action= "yonghu.php" method="post">
    <p align="center">
    用户名
    <input type="text" name="name"  size="25" maxlength="30">
    密码  
    <input type="password" name="passwd" size="15" maxlength="20">
    <br>
    </font>
    <p align="center">  <div align="center">
        <p>权限登录  
          <select name="select" >
            <option>普通用户</option>
            <option>网站管理员</option>
          </select>
        </p>
      </div>  <label>
      <div align="center">
        <input type="submit" name="Submit" value="登录">
      </div>
      </label>
    </form><p>&nbsp;</p>
    </body>
    </html>
      

  5.   

    error_reporting(E_ALL);写了,没有反应
      

  6.   

    @ $db = mysqli_connect('localhost', 'root', '123', 'ruanjiangongcheng');没有这样写法吧。
    -->  $db =@mysqli_connect('localhost', 'root', '123', 'ruanjiangongcheng'); 
      

  7.   

    @ $db = mysqli_connect('localhost', 'root', '123', 'ruanjiangongcheng');
    这里的 @ 去掉。
    $query1 = "select * from user ";
      $result = $db->query($query1);
      var_dump($result); //这里 dump 一下
      $num_results = $result->num_rows;  //这里也dump一下看看
     
      

  8.   

    $result = $db->query($query1);
    $num_results = $result->num_rows;是这样用吗?/* Connect to a MySQL server  连接数据库服务器 */   
        $link = mysqli_connect(   
                    'localhost',  /* The host to connect to 连接MySQL地址 */   
                    'user',      /* The user to connect as 连接MySQL用户名 */   
                    'password',  /* The password to use 连接MySQL密码 */   
                    'world');    /* The default database to query 连接数据库名称*/   
          
        if (!$link) {   
           printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());   
           exit;   
        }   
          
        /* Send a query to the server 向服务器发送查询请求*/   
        if ($result = mysqli_query($link, 'SELECT Name, Population FROM City ORDER BY Population DESC LIMIT 5')) {   
          
            print("Very large cities are: ");   
          
            /* Fetch the results of the query 返回查询的结果 */   
            while( $row = mysqli_fetch_assoc($result) ){   
                printf("%s (%s) ", $row['Name'], $row['Population']);   
            }   
          
            /* Destroy the result set and free the memory used for it 结束查询释放内存 */   
            mysqli_free_result($result);   
        }   
          
        /* Close the connection 关闭连接*/   
        mysqli_close($link); 
      

  9.   

    mysqli_connect 换成mysql_connect 试试
      

  10.   

    内置函数库里没有mysqli_connect这个函数吧,如果要用mysqli扩展的话应该这样用:$db = new mysqli('localhost', 'user', 'password', 'dbName');
      

  11.   

    不行啊,如果没有了那个@在$db前,会报错,说 Class 'mysqli' not found
      

  12.   

    $query1 = "select * from user ";
    你这是要干啥
    用户提交的用户名和密码都没用处吗?
    至少也应该
    $query1 = "select * from user where username='{$$name}' and password='{$passwd}'";
    吧!