I am moving to mysqli - and I know that some will say that I should go for PDO - but that's not where I am at now. My first prepared statement is not working, and I am at a loss on why. I looked at PHP documentation and it seems as I am alright. I am not getting errors - and I did provoke an error situation and got messages. It may just be on the fetch_assoc part. Please see below:
I appreciate any assistance.
$link = mysqli_connect("localhost","user","pass","db") or trigger_error($link->error);
mysqli_set_charset($link,"utf8");
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
$ct=count($arr3_modid);
if(!($stmt = $link->prepare("SELECT vbrands.* FROM vbrands WHERE model_id=? ORDER BY price"))){
echo "Prepare failed: (" . $link->errno . ") " . $link->error; }
$i=0;
for($i=0;$i <= $ct-1; $i++){
$arr3_int=(int)$arr3_modid[$i];
if(!($stmt->bind_param("i", $arr3_int))){
echo "Bind failed: (" . $stmt->errno . ") " . $stmt->error; }
if(!($stmt->execute())){
echo "execute failed: (" . $stmt->errno . ") " . $stmt->error; }
if(!($res = $stmt->get_result())){
echo "res failed: (" . $stmt->errno . ") " . $stmt->error; }
while($r3=$res->fetch_assoc()){
echo $r3['version_id];
echo.......
}
}
The variable $arr3_modid
is an array of strings.