Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in

前端 未结 1 1763
生来不讨喜
生来不讨喜 2021-01-29 11:17

I got this error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in my code is below and here it line if(mysql_num_rows($res)>

1条回答
  •  执笔经年
    2021-01-29 11:54

    The parameter that is a boolean is $res. mysql_query returns FALSE on error:

    For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

    from http://php.net/manual/en/function.mysql-query.php.

    So the problem is that your SQL query is invalid, maybe because partners_program doesn't exist or because one of the fields doesn't exist.

    A good start in debugging the problem is to remove the @ in front of mysql_query. The @ suppresses all errors and is generally frowned upon. If your PHP settings are properly set up for debugging, you should then receive a descriptive error message. You could also for debugging purposes use mysql_error() right after the mysql_query for more details.

    Also, mysql_* functions has been deprecated for a long while now, so if it is possible, you should check out the pdo or mysqli libraries instead.

    0 讨论(0)
提交回复
热议问题