Jump to content

Question confused with mysqli_stmt_store_result and mysqli_stmt_fetch


jtorral

Recommended Posts

I have this code that uses mysqli_stmt_store_result and mysqli_stmt_fetch

 

This code does NOT work:

 

$query = "SELECT userid FROM customer LIMIT 1";

 

$stmt = mysqli_prepare($connectstring, $query);

mysqli_stmt_execute($stmt);

mysqli_stmt_store_result($stmt);

mysqli_stmt_bind_result($stmt, $returnedval);

mysqli_stmt_close($stmt);

 

This code DOES work:

 

$query = "SELECT userid FROM customer LIMIT 1";

 

$stmt = mysqli_prepare($connectstring, $query);

mysqli_stmt_execute($stmt);

mysqli_stmt_bind_result($stmt, $returnedval);

mysqli_stmt_fetch($stmt);

mysqli_stmt_close($stmt);

 

I have some other code where the mysqli_stmt_store_result($stmt); does work and I thought that was a way of storing the result of the execute. Can someone explain the difference between the two statements. PHP says to always use the store but it does not work.

 

Thanks

 

JT

 

 

 

just a hunch and it is mysql page rather than mysqli BUT

 

call mysql_stmt_store_result() after binding data buffers with mysql_stmt_bind_result()

note the order seems to be the issue - source http://dev.mysql.com/doc/refman/5.0/en/mysql-stmt-store-result.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.