Reputation: 7957
Being quite new with PHP, I cannot find any solution why this does not work. The query is OK and the resource is returned. But I dunno why fetch_assoc does not print values. Thanks
$query=sprintf("SELECT ID,NAME FROM USERS WHERE PASS='%s' AND NAME='%s'",mysql_real_escape_string($p),mysql_real_escape_string($n));
$result=mysql_query($query);
if ($result)
{
while ($row = mysql_fetch_assoc($result)) {
echo $row['ID'];
echo $row['NAME'];
}
}
}
Upvotes: 2
Views: 2460
Reputation: 14959
Some simple questions to start with:
Edit:
Upvotes: 2
Reputation: 2563
Are you sure that rows were returned? You can use mysql_num_rows($result)
to get the count. The only thing I can think of looking at your code is that you're passing in the password in plain text and the version in the DB is MD5 or something.
Upvotes: 0
Reputation: 1586
1.Echo out Your $query to see if it is what You like to be for debugging purposes; 2. Check $row['ID'] AND ['NAME'] if they are really UPPER letters; 3. Use mysql error reporting after if ($result){....} else { echo mysql_errno($link) . ": " . mysql_error($link) . "\n"; } where $link is Your DB handle.
Upvotes: 0