I am trying to query a database, but it seems to just load for an age and not do anything. It's a simple query and shouldnt take longer than a millisecond.
while($row = mysql_fetch_array(getWallPosts($userid)))
{
}
Now when I replace this code with:
echo mysql_num_rows(getWallPosts($userid));
It just displays '1' in fact there's only one record in the DB and it's just a simple SELECT statement.
Here's the getWallPosts function:
function getWallPosts($userid, $limit = "10")
{
$result = dbquery("SELECT * FROM commentpost
WHERE userID = ".$userid."
ORDER BY commentPostID DESC LIMIT 0, ".$limit);
return $result;
}
Also, when I put the SQL string that it's executing into MySQL's query browser. It takes no time at all.
Any ideas?
$result = dbquery("SELECT * FROM commentpost WHERE userID = ".$userid." ORDER BY commentPostID DESC LIMIT 0, ".$limit);to$result = dbquery("SELECT * FROM commentpost WHERE userID = '".$userid."' ORDER BY commentPostID DESC LIMIT 0, ".$limit);otherwise you may suffer SQL-injection attacks (depending on where $userid came from, also note that if $limit comes from outside, there's NO WAY to protect against SQL-injection. If it's from inside you're safe