Results 1 to 3 of 3

Thread: Not a valid result resource; what?

  1. #1
    Join Date
    Sep 2011
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Not a valid result resource; what?

    Okay, I have a table with two columns..'annoyed' and 'ignored'. I poulated 'annoyed' with Bob and 'ignored' with Sally. I ran the following test due to problems I was having in my main script and I get the old MySQL "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/testing_ig.php on line 16

    Here is the code:
    PHP Code:
    <?php
    $DBhost 
    "localhost";
    $DBuser "xxxxx";
    $DBpass "xxxxx";
    $DBName "xxxxx";
    $table "ignore";

    mysql_connect($DBhost,$DBuser,$DBpass) or die();
    @
    mysql_select_db("$DBName") or die();

    $ignorequery "SELECT * FROM $table WHERE annoyed='Bob' AND ignored='Sally'";
    $checkignore mysql_query($ignorequery);
    $ifignored mysql_num_rows($checkignore); //<--- This is line 16

    if ($ifignored >= 1) {
    echo 
    "exists";
    } else {
    echo 
    "doesn't exist";
    }
    ?>
    I must be really tired because I'm not seeing the problem...?
    Last edited by Sartavius; 10-07-2011 at 02:38 AM. Reason: resolved

  2. #2
    Join Date
    Sep 2011
    Posts
    14
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    LOL, nevermind. Forgot that ignore was a reserved sql keyword.

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by Sartavius View Post
    LOL, nevermind. Forgot that ignore was a reserved sql keyword.
    use your backticks...
    Code:
    SELECT `col` FROM `table` WHERE `col`='value'
    usually unnecessary, but sometimes they solve problems and never cause any

Bookmarks

Posting Permissions

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