PHP Fatal error: Call to a member function bind_param() on a non-object in functions.php on line 339.
I have tried removing variables and hard-coding info in, but the cause of the problem continues to elude me.
This is inside a while loop, looping through multiple results from one table to find out if it exists in another to determine what it should be doing next.
$acct = 0; /*made sure the variable is clear so it IS getting the result from the database*/ $stmt = "SELECT accountNum FROM mainTable WHERE accountNum = $accountNum AND publisher = $publisher";/*this is for verifying the variables being put into the query*/ if(!$existingCheck = $existingMysqli->prepare("SELECT accountNum FROM mainTable WHERE accountNum = ? AND publisher = ?")) { echo "Prepare failed for existing check: (" . $existingMysqli->errno . ") " . $existingMysqli->error ."<BR>"; }else { $existingSTMT->bind_param("is", $accountNum, $publisher); $existingSTMT->bind_result($acct); $existingSTMT->execute(); $existingSTMT->fetch(); $results = $existingSTMT->num_rows; echo "$stmt --- Num of Results: $results, account num: $acct<BR>"; }
What it outputs is:
SELECT accountNum FROM mainTable WHERE accountNum = 123 AND publisher = XYZ --- Num of Results: 0 acct: 123
Prepare failed existing check: (0)
So it is connecting and getting the correct account number from the main table since that variable was cleared out prior, yet it keeps telling me that the query is bad. It does keep looping through and grabbing all the accounts that it should be doing, but this stops it from continuing what it needs to do.
Any ideas on where I could have gone wrong?
Thanks in advance for the help!