gpt4 book ai didi

php - 如何使用 mysqli_stmt 进行 2 个查询

转载 作者:行者123 更新时间:2023-11-30 23:23:58 25 4
gpt4 key购买 nike

如何使用 mysqli_stmt 进行 2 个查询?
如果我用一个查询实现它,如果它有效,但是用两个查询给我这个错误:
“ fatal error :在非对象中调用成员函数 execute()。”

<?
$oConni=new mysqli('localhost', 'user', 'password', 'database');

$cQuery = "SELECT email, firstname, profile_image FROM usersg";
$stmt = $oConni->prepare($cQuery);
$stmt->execute();
$stmt->bind_result($email, $name, $imagen);

$cQuery2 = "SELECT oauth_uid, oauth_token, username, imagen FROM users";
$resul = $oConni->prepare($cQuery2);
$resul->execute();
$resul->bind_result($id, $fich, $nameTwi, $imagenTwi);

echo "<table border='1'>";
while ($stmt->fetch()) {
echo "<tr>
<td>" . $email. "</td>
<td>" . $name. "</td>
<td><img src='".$imagen."' width=40px height=40px></td>
</tr>";
}
echo "</table><p>";
echo "<table border='1'>";
while ($resul->fetch()) {
echo "<tr>
<td>" . $id. "</td>
<td>" . $fich. "</td>
<td>" . $nameTwi. "</td>
<td><img src='".$imagenTwi."' width=40px height=40px></td>
</tr>";
}
echo "</table>";
?>

最佳答案

试试吧,一定会成功的!

//First Query
$cQuery = "SELECT email, firstname, profile_image FROM usersg";
$stmt = $oConni->prepare($cQuery);
$stmt->execute();
$stmt->bind_result($email, $nombre, $imagen);
echo "<table border='1'>";
while ($stmt->fetch()) {
echo "<tr>
<td>" . $email. "</td>
<td>" . $nombre. "</td>
<td><img src='".$imagen."' width=50px height=50px></td>
</tr>";
}
echo "</table>";

//Second Query
$cQuery2 = "SELECT oauth_uid, oauth_token, username, imagen FROM users";
$resul = $oConni->prepare($cQuery2);
$resul->execute();
$resul->bind_result($id, $fichero, $nombreTwitter, $imagenTwitter);
echo "<table border='1'>";
while ($resul->fetch()) {
echo "<tr>
<td>" . $id. "</td>
<td>" . $fichero. "</td>
<td>" . $nombreTwitter. "</td>
<td><img src='".$imagenTwitter."' width=50px height=50px></td>
</tr>";
}
echo "</table>";

关于php - 如何使用 mysqli_stmt 进行 2 个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14244935/

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