tags:

views:

34

answers:

3
$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["full_name"]."</a>";  // Doesnt work

echo "<a href='profil.php?id=".$showU[id]."'>".$showU["full_name"]."</a>"; // Works 
+1  A: 

Are you sure your $Vn query returns something? Try print_r($vc) after your query and see if you got any data.

UltimateBrent
+1  A: 

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.

Andrew Kozlik
+2  A: 

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.

Robert
wow, that was the solution.. it should have been uppercase B, nice find!
Karem