gpt4 book ai didi

php - 准备语句失败但没有返回错误

转载 作者:行者123 更新时间:2023-11-29 22:09:37 25 4
gpt4 key购买 nike

由于某种奇怪的原因,查询的准备失败了,我检查了一万次,参数和表都正确。这是我的代码:

foreach($decoded as $caption)
{
if($stmt = $mysqli->prepare("SELECT id, leagueCode FROM league"))
{
$stmt->bind_result($id, $leagueCode);
$stmt->execute();
var_dump($stmt);
while($stmt->fetch())
{
if($leagueCode == $caption['league'])
{
if ($stmt = $mysqli->prepare("INSERT INTO soccerseason (id, caption, league, years, numberOfTeams, numberOfGames, lastUpdated, self, teams, fixtures, leagueTable) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))
{
$id_fk = $id;
$caption = $caption['caption'];
$league = $caption['league'];
$years = $caption['year'];
$not = $caption['numberOfTeams'];
$nog = $caption['numberOfGames'];
$lu = $caption['lastUpdated'];
$self = $caption['_links']['self']['href'];
$teams = $caption['_links']['teams']['href'];
$fix = $caption['_links']['fixtures']['href'];
$lt = $caption['_links']['leagueTable']['href'];

if ($stmt->bind_param("isssiisssss", $id_fk, $caption, $league, $years, $not, $nog, $lu, $self, $teams, $fix, $lt))
{
if ($stmt->execute())
{
echo "Done!";
}
else
{
die($mysqli->error);
}
}
else
{
die($mysqli->error);
}
}
else
{

die('execute() failed: ' . $mysqli->error);
}
}
}
}

}

我试图在 else 对象中打印,但我只得到这个词

execute() failed:

else 
{
die('execute() failed: ' . $mysqli->error);
}

并且似乎$mysqli->error为空,因为它没有打印,为什么会发生这种情况?我做错了什么?

最佳答案

我终于找到了问题,我意识到,如果由于某种原因使用同一个连接,对象的参数就会丢失,所以必须在之后使用 $stmt-> store_result();的执行相同。我解决了这个问题,希望我的回答对你有帮助。

关于php - 准备语句失败但没有返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31811714/

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