[英]PHP: query, what is wrong?
$BuID= mysql_real_escape_string($_POST['buID']);
$uID= mysql_real_escape_string($_POST['uID']);
$Vn = mysql_query("SELECT id, full_name FROM users WHERE id = '$BuID'");
$vc = mysql_fetch_array($Vn);
$U = mysql_query("SELECT id, full_name FROM users WHERE id = '$uID'"); // WORKS FINE
$showU = mysql_fetch_array($U); // WORKS FINE
The $U/$showU
is similiar to the $Vn
, $vc
above, i have no idea why it wont echo out $vc["id"]
and $vc["full_name"]
, when it do it perfectly with the $U
. $U/$showU
与$Vn
, $vc
相似,我不知道为什么它在与$U
完美配合时不会回显$vc["id"]
和$vc["full_name"]
$U
。
echo "<a href='profil.php?id=".$vc[id]."'>e".$vc["full_name"]."</a>"; // Doesnt work
echo "<a href='profil.php?id=".$showU[id]."'>".$showU["full_name"]."</a>"; // Works
The query is syntactically correct, the error may be coming from the escaping of $_POST['buiD']
(is it supposed to be lowercase b?). 该查询在语法上是正确的,该错误可能来自
$_POST['buiD']
的转义(是否应该是小写的b?)。 Your best bet is to echo out the query; 最好的选择是回显查询。 if it looks good, manually run it and see if it returns any rows.
如果看起来不错,请手动运行它,看看它是否返回任何行。
Are you sure your $Vn query returns something? 您确定$ Vn查询返回什么吗? Try
print_r($vc)
after your query and see if you got any data. 查询后尝试使用
print_r($vc)
,看看是否有任何数据。
When you echo out the two sql statements what do you see? 当您回显两个sql语句时,您会看到什么?
$BuID= mysql_real_escape_string($_POST['buID']);
$uID= mysql_real_escape_string($_POST['uID']);
$sql = "select id, full_name from users where id = '$BuID'";
$sql2 = "select id, full_name FROM users WHERE id = '$uID'";
echo "<p>$sql</p>";
echo "<p>$sql2</p>";
Check to make sure that the statement with the $BuID variable is being formed correctly. 检查以确保带有$ BuID变量的语句格式正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.