开发者

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.

echo "<a href='profil.php?id=".$vc[id]."'>e".$vc开发者_JS百科["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?). 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? Try print_r($vc) after your query and see if you got any data.


When you echo out the two sql statements what do you see?

$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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜