...

View Full Version : Resolved MySQLi STMT Multiple Queries



tyanque
04-16-2012, 07:59 PM
Hey,
I'm having a problem with sending more than one MySQLi Query in a function the first query executes successfully:


$stmt = mysqli_prepare($link, "SELECT userEmail FROM onlinestorage.users WHERE userEmail=? LIMIT 1");
// Bind Param
mysqli_stmt_bind_param($stmt, "s", $email);

// Execute
mysqli_stmt_execute($stmt);

// Store Result
mysqli_stmt_store_result($stmt);

// Fetch Result
$NumRows = mysqli_stmt_num_rows($stmt);
mysqli_stmt_free_result($stmt);
mysqli_stmt_close($stmt);


Then later in the function I have called MySQLi again to do an insert query but it gives errors. Here is the code for the second query:


// Store Information In Database
$stmt = mysqli_prepare($link, "INSERT INTO onlinestorage.users(userFullName, userEmail, userMemorableInfo) VALUES(?, ?, ?)");

// Bind Param
mysqli_stmt_bind_param($stmt, "sss", $userFullName, $userEmail, $userMemInfo);

// Execute
mysqli_stmt_execute($stmt);


And I get the following errors:


Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given.

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given.


Any ideas to what the problem may be? Is there anything you have to do after running a MySQLi query?

Thanks for any help.

Fou-Lu
04-16-2012, 08:10 PM
False indicates that your statement failed to compile. Make sure you have a space between the VALUES and the (, as well as double checking the field and table names.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum