mysqli_stmt_bind_param ::变量的问题不是绑定! [英] Problem with mysqli_stmt_bind_param :: Variables are not Binding!
问题描述
这是我的代码:
<?php
$ mysqli = new mysqli(" localhost"," ***) *"," ********"," ***********");
$ idNum =" ; 1030"
$ sql =" select id,来自用户的电子邮件,其中id?;" ;;
$ stmt = $ mysqli->准备($ sql);
$ stmt-> bind_param('s'',$ idNum);
$ stmt-> execute();
$ stmt-> bind_result($ id,$ email);
while($ stmt-> fetch()){
printf("%s(%s)< br /> \ n",$ id,$ email);
}
?>
显然,这应该做的是将$ idNum(值1030)绑定到
SQL语句并将其发送到MySQL服务器 - 选择id,发送电子邮件
来自id为''1030''的用户;这应该返回10行。
但是,这不是正在发生的事情。发生的事情是
变量没有绑定,这是发送-select id,email
来自id''''的用户;因此,它返回1040
行。
我已经在许多不同场景中对此进行了测试。无论我做什么,
变量都没有约束力。
任何想法为什么会发生这种情况?我假设它是一个服务器
配置问题。即使你能想到多个原因,我能否听到一些可能性?我很茫然!
mysqli = new mysqli(" localhost"," ****" ;,********,***********;;
idNum =" 1030" ;;
sql =" select id,来自用户的电子邮件,其中id ?;" ;;
Here''s my code:
<?php
$mysqli = new mysqli("localhost", "****", "********", "***********");
$idNum = "1030";
$sql = "select id,email from users where id ?;";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param(''s'', $idNum);
$stmt->execute();
$stmt->bind_result($id, $email);
while ($stmt->fetch()) {
printf ("%s (%s)<br/>\n", $id, $email);
}
?>
Obviously, what this should do is bind $idNum (value of 1030) to the
SQL statement and send this to the MySQL server -select id,email
from users where id ''1030''; This should return 10 rows.
However, this is not what''s happening. What''s happening is that the
variable is not being binded and this is being sent -select id,email
from users where id ''''; And because of this, it''s returning 1040
rows.
I''ve tested this on many different scenarios. No matter what I do,
the variables are not binding.
Any idea why this could be happening? I''m assuming it''s a server
config issue. Even if you can think of more than one reason, can I
hear some possibilities? I''m at a loss!
mysqli = new mysqli("localhost", "****", "********", "***********");
idNum = "1030";
sql = "select id,email from users where id ?;";
这篇关于mysqli_stmt_bind_param ::变量的问题不是绑定!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!