MySQL Forums
Forum List  »  PHP

Re: mysql_fetch_array() expects parameter 1 to be resource, boolean
Posted by: Peter Brawley
Date: May 13, 2014 12:35PM

First, use the mysqli API, not the mysql API, which is deprecated and will be removed.

Second, check the return value of functions that can fail.

Third, the repeat call to the query func makes no sense.

$conn = mysqli_connect("localhost", "root", "", "paragon") 
        or die (mysqli_connect_error() ); 

$strSQL = "SELECT * FROM table"; 
$rs = mysqli_query( $conn, $strSQL ) or exit( mysqli_error( $conn ); 

while( $rs && $row=mysqli__fetch_array($rs) ) { 
 ...
}

Options: ReplyQuote


Subject
Written By
Posted
Re: mysql_fetch_array() expects parameter 1 to be resource, boolean
May 13, 2014 12:35PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.