Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    what does this error annoucement mean?

    hi!!!
    What does it mean in this error announcement?
    /*
    Film Search Results

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\phpdev\www\foreveryoung\searching.php on line 17

    Number of films found:
    */
    Can you explain more about the command:
    mysql_num_rows()
    Thanks

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    It returns the number of records returned by a query.

    http://us2.php.net/manual/en/functio...l-num-rows.php

  • #3
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts
    usually means something is awry in your SQL query. (Either it isn't properly structured, and/or is returning 0 results)

    Try echoing your SQL statement to make sure it is correct.

  • #4
    New Coder
    Join Date
    Sep 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do try the command line with my Database, it works ...
    however, there is one problem with the connection from the html page to the php one..
    I need your help in detecting the error:
    here is the html script:
    <form action="resultsb.php" method="post">

    <h3 style="color:#ffffff">Choose search Type:</h3>
    <br>
    <select name="searchtype">
    <option value="title">Film title</option>
    <option value="director">Director</option>
    <option value="presentingdate">Showing Date</option>
    </select>
    <br>
    <h3 style="color:#ffffff">Enter Search Term:</h3>
    <br>
    <input name="searchterm" type="text">
    <br>
    <br>
    <input type="submit" value="Search">
    </form>
    And here is the php script:
    <?php
    trim($searchterm);
    if (!$searchtype ||!$searchterm)
    {
    echo "You have not entered search details.Please go back and try again.";
    exit;
    }

    $searchtype=addslashes($searchtype);
    $searchterm=addslashes($searchterm);

    $db= mysql_connect("localhost");

    if (!$db)
    {
    echo "Error: Could not connect to databases. Please try again later.";
    exit;
    }

    mysql_select_db("test");
    $query="SELECT * FROM film WHERE ".$searchtype. "like '%".$searchterm. "%'";
    $result= mysql_query($query);
    $num_results=mysql_num_rows($result);
    echo "<p>Number of films found: ".$num_results."</p>";
    for ($i=0; $i<$num_results; $i++)
    {
    $row= mysql_fetch_array($result);
    echo "<p><strong>".($i+1).". Title:";
    echo htmlspecialchars(stripslashes($row["title"]));
    echo "</strong><br>Director: ";
    echo htmlspecialchars(stripslashes($row["director"]));
    echo "<br>Presenting Date:";
    echo htmlspecialchars(stripslashes($row["presentingdate"]));
    echo"</p>";
    }

    ?>

  • #5
    New Coder
    Join Date
    Sep 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do try the command line with my Database, it works ...
    however, there is one problem with the connection from the html page to the php one..
    I need your help in detecting the error:
    here is the html script:
    <form action="resultsb.php" method="post">

    <h3 style="color:#ffffff">Choose search Type:</h3>
    <br>
    <select name="searchtype">
    <option value="title">Film title</option>
    <option value="director">Director</option>
    <option value="presentingdate">Showing Date</option>
    </select>
    <br>
    <h3 style="color:#ffffff">Enter Search Term:</h3>
    <br>
    <input name="searchterm" type="text">
    <br>
    <br>
    <input type="submit" value="Search">
    </form>
    And here is the php script:
    <?php
    trim($searchterm);
    if (!$searchtype ||!$searchterm)
    {
    echo "You have not entered search details.Please go back and try again.";
    exit;
    }

    $searchtype=addslashes($searchtype);
    $searchterm=addslashes($searchterm);

    $db= mysql_connect("localhost");

    if (!$db)
    {
    echo "Error: Could not connect to databases. Please try again later.";
    exit;
    }

    mysql_select_db("test");
    $query="SELECT * FROM film WHERE ".$searchtype. "like '%".$searchterm. "%'";
    $result= mysql_query($query);
    $num_results=mysql_num_rows($result);

    echo "<p>Number of films found: ".$num_results."</p>";

    for ($i=0; $i<$num_results; $i++)
    {
    $row= mysql_fetch_array($result);
    echo "<p><strong>".($i+1).". Title:";
    echo htmlspecialchars(stripslashes($row["title"]));
    echo "</strong><br>Director: ";
    echo htmlspecialchars(stripslashes($row["director"]));
    echo "<br>Presenting Date:";
    echo htmlspecialchars(stripslashes($row["presentingdate"]));
    echo"</p>";
    }

    ?>

  • #6
    New Coder
    Join Date
    Sep 2004
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do try the command line with my Database, it works ...
    however, there is one problem with the connection from the html page to the php one..
    I need your help in detecting the error:
    here is the html script:
    <form action="resultsb.php" method="post">

    <h3 style="color:#ffffff">Choose search Type:</h3>
    <br>
    <select name="searchtype">
    <option value="title">Film title</option>
    <option value="director">Director</option>
    <option value="presentingdate">Showing Date</option>
    </select>
    <br>
    <h3 style="color:#ffffff">Enter Search Term:</h3>
    <br>
    <input name="searchterm" type="text">
    <br>
    <br>
    <input type="submit" value="Search">
    </form>
    And here is the php script:
    <?php
    trim($searchterm);
    if (!$searchtype ||!$searchterm)
    {
    echo "You have not entered search details.Please go back and try again.";
    exit;
    }

    $searchtype=addslashes($searchtype);
    $searchterm=addslashes($searchterm);

    $db= mysql_connect("localhost");

    if (!$db)
    {
    echo "Error: Could not connect to databases. Please try again later.";
    exit;
    }

    mysql_select_db("test");
    $query="SELECT * FROM film WHERE ".$searchtype. "like '%".$searchterm. "%'";
    $result= mysql_query($query);
    $num_results=mysql_num_rows($result);

    echo "<p>Number of films found: ".$num_results."</p>";

    for ($i=0; $i<$num_results; $i++)
    {
    $row= mysql_fetch_array($result);
    echo "<p><strong>".($i+1).". Title:";
    echo htmlspecialchars(stripslashes($row["title"]));
    echo "</strong><br>Director: ";
    echo htmlspecialchars(stripslashes($row["director"]));
    echo "<br>Presenting Date:";
    echo htmlspecialchars(stripslashes($row["presentingdate"]));
    echo"</p>";
    }

    ?>
    I think it gets wrong from the connection between html and php site, because I try to print out the $searchterm before and after the trim() function, it doesn't appear anything..Beside,when I drop the checking value whether the user fill up the text form or not(if (!$searchtype ||!$searchterm)
    {
    echo "You have not entered search details.Please go back and try again.";
    exit;
    }

    )
    an error message appears on the screen:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\phpdev\www\foreverlove\resultsb.php on line 25

    Number of films found:

    Thank you!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •