That is because it is getting into else
part of the statement , which means $result
is 0 or false.
So the reason is the query must be failing.. So add mysql_error()
like this..
$result=mysql_query($qry) or die(mysql_error());
To know the exact cause..
This(mysql_*
) extension is deprecated as of PHP 5.5.0
, and will be removed in the future. Instead, the MySQLi
or PDO_MySQL
extension should be used. Switching to PreparedStatements
is even more better to ward off SQL Injection attacks !