Page 1 of 1

[SOLVED] Confusing 'not a valid MySQL result resource' error

Posted: Sat Jul 24, 2004 6:01 am
by mjseaden
Dear All,

For this piece of code:

Code: Select all

$query5 = 'SELECT * FROM CommissionTermPayments WHERE CustomerID='.$row2['CustomerID'].' AND CommissionTermID='.$row4['CommissionTermID'];
        $myresult5 = mysql_fetch_array( $query5 );
        
        if(!$myresult5)
        {
            do_html_message('Error: Could not perform MySQL query - '.mysql_error());
            do_html_footer();
            exit();
        }
I get the following error:

Code: Select all

Warning: Supplied argument is not a valid MySQL result resource in /home/XXXX/public_html/sales.php on line 102
Line 102 is the mysql_query line. I have had a problem like this just previous to this, which I solved by substituting the variable '$result' for '$myresult'. It now works.

I've never had this problem before and this doesn't seem to work this time. It would be best to understand the underlying cause.

Can anyone elaborate on why it is doing this?

Many thanks

Mark

Posted: Sat Jul 24, 2004 6:02 am
by mjseaden
I'll also add that it is producing an error - however mysql_error() is returning an empty string.

Posted: Sat Jul 24, 2004 6:46 am
by redmonkey
You are not actually querying the database so.....

Code: Select all

$query5 = 'SELECT * FROM CommissionTermPayments WHERE CustomerID='.$row2['CustomerID'].' AND CommissionTermID='.$row4['CommissionTermID'];

$query5res = mysql_query($query5);

$myresult5 = mysql_fetch_array( $query5res );

Posted: Sat Jul 24, 2004 6:52 am
by mjseaden
doh