gpt4 book ai didi

PHP 不提交 mysql 查询

转载 作者:行者123 更新时间:2023-11-29 12:14:32 25 4
gpt4 key购买 nike

显然 IF 语句的计算结果为 false,我不知道为什么。即使当我从 if 语句中提取 $mysqli->multi_query($dbq) 时,数据库也不会被查询。当在 phpmyadmin 中使用三个 UPDATE 语句时,它们工作得很好。我的其他脚本使用 multi_query 工作正常,所以我有点困惑为什么它不能。知道为什么以及我需要改变什么吗?

$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();

更新:这是查询:

$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`;";

更新2:没有错误消息。屏幕保持白色。

最佳答案

问题出在您的查询中:当您使用 instr 时,您应该这样转义双引号:

$dbq="UPDATE `table1` as t1, `table2` as t2,`table3` as t3 
SET t1.`na`=right(t3.QuestionAnswer,instr(reverse(t3.QuestionAnswer),\";\")-1),
[.. cut ..] ^----
";

此外,您不会收到任何错误,因为错误报告被禁用。检查here如何启用它。

关于PHP 不提交 mysql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30052944/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com