RE :[PHP-DB] MySQLi Help

Olivier Desmares <[email protected]>
Newsgroups gmane.comp.php.database
Message-ID <466741615.69996.1339858718931.JavaMail.www@wwinf1w27>
Hi James,

The manual page for mysqli_stmt::execute has the following note :

When using mysqli_stmt_execute(), the 
    mysqli_stmt_fetch() function must be used to fetch the
    data prior to performing any additional queries.
   

So you cannot execute the inner (sub) query without first retrieving all the rows from the outer (main) query.

Olivier Desmares

 $stmt = mysqli_prepare($db, $sql);
 mysqli_stmt_execute($stmt);
 mysqli_stmt_bind_result($stmt, $authkv);
 
 while (mysqli_stmt_fetch($stmt)) {
 echo "&lt;p&gt;MAIN: $authkv&lt;/p&gt;";
 sub($db);
} 
 
 mysqli_stmt_close($stmt);
 
This simple change results in the output.
 
MAIN: 7
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt,  boolean given in /var/www/html/xgwebapi/mysqli.php on line 21  Warning: mysqli_stmt_bind_result() expects parameter 1 to be  mysqli_stmt, boolean given in /var/www/html/xgwebapi/mysqli.php on line  22  Warning: mysqli_stmt_fetch() expects parameter 1 to be mysqli_stmt,  boolean given in /var/www/html/xgwebapi/mysqli.php on line 24  Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt,  boolean given in /var/www/html/xgwebapi/mysqli.php on line 28
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.