Form to MySQL - Warning: mysql_numrows() expects parameter 1 to be resource

  • Profile Image
    Asked on November 27, 2014 at 12:59 PM

    When you get the error below. Try going into phpMyAdmin and adding one row of bogus data to your table. That way, when it counts the number of rows it will find 1 (it is looking for more than zero)


    Warning: mysql_numrows() expects parameter 1 to be resource, boolean given in line 33

    Below is the 33 in my file. "$resultcount = mysql_numrows($sqlsearch);

    This is a re-post of a comment on How to send Submissions to Your MySQL Database Using PHP

  • Profile Image
    Answered on November 27, 2014 at 02:57 PM

    Thank you for contacting us.

    Do you mean that you solve the problem by adding a row to your MySQL table, or the issue is till there?

  • Profile Image
    Answered on November 27, 2014 at 08:40 PM

    It solved the problem for me because the code below basically says 'if resultcount is greater than zero, then proceed'  and resultcount is a count of the number of rows in the sql table. I'm not sure that code is needed, but when you start with new / empty table it will always count zero rows and fail.

    $query = "SELECT * FROM `table_name` WHERE `submission_id` = '$submission_id'"; $sqlsearch = mysql_query($query); $resultcount = mysql_numrows($sqlsearch); if ($resultcount > 0) {


  • Profile Image
    Answered on November 28, 2014 at 06:06 AM

    Thanks for that helpful information. Should anyone report the error, we'll suggest your solution.