Apparently the IF
statement evaluates false
, and I have no idea why. Even when I pull $mysqli->multi_query($dbq)
out of the if
statement, the database doesn't get queried.
When using the three UPDATE
statements in phpmyadmin they work just fine. My other script works fine, using multi_query
, so I am a bit puzzled why this won't.
Any idea why and what I need to change?
$dbq="UDATE ...;UPDATE ...;UPDATE ...;";
$mysqli = new mysqli("localhost", "root","","test");
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
//$result=$mysqli->multi_query($dbq);
if($mysqli->multi_query($dbq))
{
do
{
if($result=$mysqli->store_result())
{
$up_cnt = $mysqli->affected_rows;
echo "Affected rows: $up_cnt<br />";
$result->free();
}
if($mysqli->more_results())
{
print("-------------------------------<br/>");
}
else
{
echo '<br/>';
}
}while($mysqli->more_results() && $mysqli->next_result());
}
$mysqli->close();
UPDATE: Here's the query:
$dbq="UPDATE `table1` as t1, `table2` as t2,`table3` as t3
SET t1.`na`=right(t3.QuestionAnswer,instr(reverse(t3.QuestionAnswer),";")-1), t1.`xa`= CASE right(t3.QuestionAnswer,instr(reverse(t3.QuestionAnswer),";")-1)
WHEN 'Low' THEN 1
WHEN 'Medium' THEN 2
WHEN 'High' THEN 3
WHEN 'Very High' THEN 4
ELSE 0
END
WHERE t3.`sfGroup`='finalAnswer' AND t2.`Status`='Approved' AND t3.`Subprocess`='A' AND t1.`na` IS NULL AND t1.`sfid`=t2.`ITP` AND t2.`sfid`=t3.`BIA`;
UPDATE `table1` as t1, `table2` as t2,`table3` as t3
SET t1.`ni`=t3.`QuestionAnswer` , t1.`xi`= CASE t3.`QuestionAnswer`
WHEN 'Low' THEN 1
WHEN 'Medium' THEN 2
WHEN 'High' THEN 3
WHEN 'Very High' THEN 4
ELSE 0
END
WHERE t3.`sfGroup`='finalAnswer' AND t2.`Status`='Approved' AND t3.`Subprocess`='I' AND t1.`ni` IS NULL AND t1.`sfid`=t2.`ITP` AND t2.`sfid`=t3.`BIA`;
UPDATE `table1` as t1, `table2` as t2,`table3` as t3
SET t1.`nc`=t3.`QuestionAnswer` , t1.`xc`= CASE t3.`QuestionAnswer`
WHEN 'Low' THEN 1
WHEN 'Medium' THEN 2
WHEN 'High' THEN 3
WHEN 'Very High' THEN 4
ELSE 0
END
WHERE t3.`sfGroup`='finalAnswer' AND t2.`Status`='Approved' AND t3.`Subprocess`='C' AND t1.`nc` IS NULL AND t1.`sfid`=t2.`ITP` AND t2.`sfid`=t3.`BIA`;";
UPDATE 2: There's no error message. The screen remains white.