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 4 of 4

Thread: Error Help

  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Error Help

    Well heres my code

    PHP Code:
    <?php
    $con 
    mysql_connect('localhost','root','') or die(mysql_error());
    mysql_select_db('blog',$con);

    $query "SELECT * FROM `content` WHERE ID = `1`";
    $res mysql_query($query);

    $post mysql_num_rows($res);

    echo 
    "<h1>" $post['title'] . "</h1>";
    echo 
    "<h3>" $post['date'] . "</h3>";
    echo 
    "<p>" $post['content'] . "</p>";

    ?>
    and heres my error

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\tests\Variables.php on line 8
    Kevin

  • #2
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    Change the quote of the 1 to regular single quote.
    PHP Code:
    $query "SELECT * FROM `content` WHERE ID = '1'"

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Hey thanks, how im getting
    Warning: Wrong parameter count for mysql_num_rows() in C:\wamp\www\tests\Variables.php on line 8
    Kevin

  • #4
    Regular Coder kokjj87's Avatar
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    279
    Thanks
    1
    Thanked 55 Times in 54 Posts
    Because the query has fail, so $res would not be a valid result set..

    Place a die statement and you can see the query fail
    PHP Code:
    $res mysql_query($query) or die(mysql_error()); 


  •  

    Posting Permissions

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