mysql_num_rows(): supplied argument is not a valid MySQL result resource

前端 未结 1 637
清酒与你
清酒与你 2021-01-24 03:52

I am getting this error when I pass an invalid SQL string... I spent the last hour trying to find the problem assuming - It\'s not my SQL it must be the db handle... ANyway, I\'

相关标签:
1条回答
  • 2021-01-24 04:23

    mysql_query will return false if there is an error

    $result = mysql_query('select * from');
    if ($result === false) {
        // caused by my invalid input above
    } else {
        // process as usual
    }
    

    In fact, you're getting the error you describe because you're literally calling mysql_num_rows(false)

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