Resource id #2
Results 1 to 3 of 3

Thread: Resource id #2

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    1

    Resource id #2

    Hello,

    I have this weird output "Resource id #2" when I browse the file with the code that is below. It is strange, because this code DID work on another server. Does anybody know what I'm doing wrong or how I should re-configure my PHP or MySql?

    Thanks. Here is the code

    <body>
    <?
    include("db.inc.php");
    mysql_connect($server,$username,$password);
    @mysql_select_db($database) or die(mysql_error());

    $query = "SELECT * FROM solas_rel WHERE $methode LIKE '$keyword%' ORDER BY achternaam ASC";
    $result = mysql_query($query);
    echo "debug $result";
    $num = mysql_numrows($result);
    mysql_close();



    if ($num == 0) {
    echo "Geen resultaten gevonden.";
    }

    if ($num > 0) {
    include("rel_zoek_result.php");
    }

    ?>

    Here is the output:
    Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /Users/stijn/Sites/solas/rel_zoek_do.php on line 18

  2. #2
    Member
    Join Date
    Apr 2002
    Location
    Bristol, UK
    Posts
    98
    How about this:
    PHP Code:
    <? php
    include("db.inc.php"); 

    /* assign the connection to $link */
    $link mysql_connect($server,$username,$password); 

    @
    mysql_select_db($database) or die(mysql_error()); 

    $query "SELECT * FROM solas_rel WHERE $methode LIKE '$keyword%' ORDER BY achternaam ASC"
    $result mysql_query($query$link);  /* link parameter supplied */
    $num mysql_numrows($result); 
    mysql_close($link); 

    ...

    ?>
    Also, you cannot print a result variable. That is where the "Resource id #2" is coming from.
    God is not all powerful as he cannot build a wall he cannot jump

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    9,761
    Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in

    means that your query simply was not valid.

    most likely the variables inside the query are empty, breaking the syntax. Print the query to see what's going on.

    You can print the exact error like this:

    <?
    $query = "SELECT * FROM solas_rel WHERE $methode LIKE '$keyword%' ORDER BY achternaam ASC";
    if (!$result = mysql_query($query))
    {
    echo 'Query failed:'.$query.'<BR>'.mysql_error();
    }
    else
    {
    // query ok, continue processing.
    }
    ?>
    www.yapf.net, everything PHP, in Dutch and English
    Linux + Apache + PHP + PostgreSQL = success

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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