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

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.