Hi, i keep getting the error:
supplied argument is not a valid MySQL result resource
randomly in my mysql coding, I'm doing the statements correctly, like ive always done them, but recently when I type new mysql statements, i get that error when i load the page, im only getting it on the statements ive written recently, the ones already on that page work fine, i have concluded that there is no reason for this, its happening on everything from mysql_result() to mysql_numrows() to mysql_query(). Is there a problem with mysql on my server, could an update have caused this? It started 2 days ago, and since then I can't do any mysql, but the code that was previously on the pages works. I'm so cunfused. Can Some1 please help me?

    what does [man]mysql_error[/man] have to say about your query(s)?

      It is possible that the query failed, or that you failed to connect to the database server. Checking for these potential problems and gracefully handling them should be the way to go.

      Incidentally, use mysql_num_rows() not mysql_numrows() as the latter is deprecated.

        awww man, i feel stupid, i added
        or die(mysql_error()) to the queries and it turns out i thought those certain tables were in a different DB,
        thanks for your help.

          No, im still getting that error on another page, the mysql error turned out to be:
          You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'values WHERE type = '$rowval' at line 1
          my query was:
          SELECT * FROM values WHERE type = '$rowval'
          i dont see why im all of a sudden getting these errors, im doing everything the same as ive always done them, i dont see anything wrong with the syntax.
          note: I got the exact same error when i had type displayed 'type' and when i had values displayed 'values' (with quotes), and i had it when both were in quotes, has the syntax changed that drasticly? Please help me. my MySQL verison is 4.1.13

            Using "values" as a table name could create problems since values is a mysql keyword. Try changing the table name and see if it starts working.

              8 months later

              The same thing...???

              I am using the following code:

              $membernum=$GET['memid'];
              $loginpassword=$
              GET['logpw'];

              $user="webchef8_webchef";
              $host="localhost";
              $password="dbedit8";
              $database = "webchef8_lgt";

              $connection = mysql_connect($host,$user,$password)
              or die ("couldn't connect to server");
              $db = mysql_select_db($database, $connection)
              or die ("Couldn't select database");

              $query="SELECT * FROM contacts WHERE MEMID='$membernum'";
              $result=mysql_query($query);
              $num=mysql_num_rows($result);
              mysql_close();

              echo "$num";

              $i=0;
              while ($i < $num) {
              $memid=mysql_result($result,$i,"memid");
              //$lpw=mysql_result($result,$i,"logpw");

              //Space For Code

              ++$i;
              }

              ...and get the error. What am I coding incorrectly?

                Write a Reply...