使用准备好的语句返回特定行
我有一个问题,我准备好的语句似乎只返回返回的行数而不是行的值。下面是我的代码。我确实尝试过谷歌,但它没有告诉我任何东西!如果有人能告诉我我做错了什么以及如何解决它,我将非常感激。谢谢
$query2 = 'SELECT * FROM kids_entry WHERE email = ?';
$stmt2 = $connection->prepare($query2);
// bind the user id as an integer to the first ?
$stmt2->bind_param('s', $email);
$stmt2->execute(); // execute the statement
$stmt2->store_result(); // this call is required for the next operation
while($row1 = $stmt2->fetch()){
printf ("%s \n", $entries);
}
编辑
我只是尝试用 while 循环替换 if ,我得到了同样的结果。
编辑2
添加新代码后,它可以工作,但是我如何将其分配给$变量?
I have a problem where my prepared statement appears to only be returning the number of rows returned rather than the value of the row. Below is my code. I did try google for this but it doesn't tell me anything! If someone could tell me what I am doing wrong and how to fix it I would be very appreciative. Thanks
$query2 = 'SELECT * FROM kids_entry WHERE email = ?';
$stmt2 = $connection->prepare($query2);
// bind the user id as an integer to the first ?
$stmt2->bind_param('s', $email);
$stmt2->execute(); // execute the statement
$stmt2->store_result(); // this call is required for the next operation
while($row1 = $stmt2->fetch()){
printf ("%s \n", $entries);
}
EDIT
I did just try replacing the if with a while loop and i got the same thing.
EDIT 2
Having added the new code it works but how would i assign this to a $variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅 php 文档中的示例:
mysqli_stmt_fetch
See the example in the php documentation:
mysqli_stmt_fetch