php - bind_param not working (on a non-object) mysqli prepared statement -
i have read 15 posts on here far regarding issues none of have been able me.
i have following code:
$stmt3 = $mysqli->prepare("select cc.name, cc.company, cc.email (`case_contacts` cc) cc.case_id=? , cc.end_date null"); if (is_object($stmt3)) { $stmt3 -> bind_param("i", $case_id); } else { die('connection issue'); } $stmt3 -> execute(); $stmt3 -> bind_result($name, $company, $email); while ($stmt3->fetch()) {
when execute advises "connection issue". before $stmt3
can var_dump $mysqli
quite happily.
i have manually entered query both phpmyadmin , online query checker , both confirm valid.
i have checked permissions of user, fine. in fact in process of re-writing queries mysql mysqli , wantedto use prepared statements. database user same. have had no issues other prepared statements more complex @ loss missing.
i have overkilled '`' quote wrap on statement know should on every query!
any advice, debugging tips great. have had around , ones have found not providing output.
mysqli_stmt::prepare ( string $query )
return true
or false
read more at:
you can use example:
<?php $mysqli = mysqli_connect('localhost', 'root', 'admin', 'test'); $case_id = 603; $sentence = $mysqli->stmt_init(); if($sentence->prepare("select name, company, email case_contacts case_id = ? , end_date null")) { $sentence->bind_param("i", $case_id); $sentence->execute(); $sentence->bind_result($name, $company, $email); while ($sentence->fetch()) { echo $name . ' - ' . $company . ' - ' . $email; } }