0

I have one php code,when I execute it says mysql_num_rows parameter 1 to be resource boolean given,can you help me how do i write that line,

$sqlusername=mysql_query("select * from candidate where (username='".$uname."' or emailid='".$emailid."' or mobileno='".$mobileno."')");
 if(mysql_num_rows($sqlusername) > 0)

can you help me...

  • First you check your query is working or not!!! – Saty Jul 09 '15 at 12:46
  • If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jul 09 '15 at 12:47
  • [Your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) – Jay Blanchard Jul 09 '15 at 12:48

1 Answers1

0

1.) Please, don't use mysql_ functions! They are deprecated, and will stop working in future php versions. Use the mysqli_-functions instead (Almost the same handling), or use PDO.

2.) Your Query has probably an error. The database tells you about the error, so you have to display it:

if(!$sqlusername){
    print_r(mysql_error($your_db_variable));
}

Post the error-message of the Database and we can say what is wrong.

Michael B
  • 1,627
  • 3
  • 26
  • 54