dshmkgq558192365
2015-12-24 06:44
浏览 258

错误:警告:mysqli_fetch_array()要求参数1为mysqli_result,第15行/var/www/html/data.php中给出布尔值[复制]

I am trying to select data from a MySQL table to show data's in my c# datagridview, but I get one of the following error messages:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/data.php on line 15

This is my PHP code:

<?php 

$servername = "********";
$username = "root";
$password = "pws";
$dbname = "dbs";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
$sql = "SELECT userid,password,first_name,last_name,role,active FROM aster_users";
$result = mysql_query($sql);
while($row = mysqli_fetch_array($result)) 
    {
        $userid=$row['userid'];
        $password=$row['password'];
        $first_name=$row['first_name'];
        $last_name=$row['last_name'];
        $role=$row['role'];
        $active=$row['active'];
    }
$conn->close();
?>

Help me,

</div>

图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:</ p>

  • mysql_fetch_array()/ mysql_fetch_assoc()/ mysql_fetch_row()/ mysql_num_rows etc ...期望参数1为资源或结果 32 answers </ span> </ li> </ ul> </ div>

    我试图从MySQL表中选择数据来显示我的c#datagridview中的数据,但是我收到以下错误消息之一:</ p>

    警告:mysqli_fetch_array()要求参数1为mysqli_result,在第15行的/var/www/html/data.php中给出 布尔值</ p> </ blockquote>

    这是我的PHP代码:</ p>

     &lt;?php 
     
     $ servername =“**  ******“; 
     $ username =”root“; 
     $ password =”pws“; 
     $ dbname =”dbs“; 
     
     $ conn = new mysqli($ servername,$ username  ,$ password,$ dbname); 
     
    if($ conn-&gt; connect_error){
     die(“连接失败:”。  $ conn-&gt; connect_error); 
    } 
     $ sql =“SELECT userid,password,first_name,last_name,role,active FROM aster_users”; 
     $ result = mysql_query($ sql); 
    while($ row =  mysqli_fetch_array($ result))
     {
     $ userid = $ row ['userid']; 
     $ password = $ row ['password']; 
     $ first_name = $ row ['first_name']; 
      $ last_name = $ row ['last_name']; 
     $ role = $ row ['role']; 
     $ active = $ row ['active']; 
    } 
     $ conn-&gt; close()  ; 
    ?&gt; 
     </ code> </ pre> 
     
     

    帮帮我,</ p> </ div>

3条回答 默认 最新

相关推荐 更多相似问题