There must be an error in the query of some sort.
First off, I don't see a mysql_connect()
. It is probably in an included file. Check to make sure there is no error for the connection (mysql_error()
after the connection).
You can also check:
if (!mysql_query($sql)) {
echo mysql_error();
}
That will show you any error in the query.
You should also look into SQL Injection and a DB Wrapper (I suggest PDO). PDO can be set up to throw an exception on errors so you will definitely know about them.