You got this error. Because your query return nothing. I request you to use die(mysql_error()) next to your mysql query. If you use this, then you'll get mysql error. Another option is, before execute query, echo the query, copy and past it to mysql database to see whether it give correct answer or not.