Solved

supplied argument is not a valid MySQL result resource

Posted on 2006-10-20
5
168 Views
Last Modified: 2006-11-21
I know this question has been asked a number of times but I cannot seem to get the solution from looking at the previous responses.

I have a php page that doing a number of calculations to display a league table.
I know that the connection to the database is fine as the previous queries on the same page are all working ok.

The code that is causing the problem is as follows.

88.$mysql = "SELECT ap.player_id,ap.position
89.               FROM mfhc_apps ap
90.               LEFT JOIN mfhc_matches ma ON ma.match_id = ap.match_id
91.              WHERE ap.player_id IN (".$myin.") AND ma.comp_id IN (1,2,3,4) AND ma.oppscore = 0";
92.         $myresult = mysql_query($mysql) or die(mysql_error());
93.      
94. //Set up loop to work out clean sheets
95.      while ($temp=mysql_fetch_array($myresult))
              {
                         ...some other code
                         }
The $mysql generates the following query

SELECT ap.player_id,ap.position FROM mfhc_apps ap LEFT JOIN mfhc_matches ma ON ma.match_id = ap.match_id WHERE ap.player_id IN (27,30,98,36,26,56,5,33,91,87,68) AND ma.comp_id IN (1,2,3,4) AND ma.oppscore = 0

Which if entered directly into MYPHPADMIN produces a valid result.

The error message I am getting is as follows

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/martonhockey_co_uk/tests/fantasyleague.php on line 95

This has been bugging me for ages know am getting a bit sick, please help
0
Comment
Question by:Duggie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 8

Expert Comment

by:Yuval_Shohat
ID: 17775096
after executing the query and before the while loop try:
echo "myresult=".$myresult;
check to see what it contains...


-=Yuval=-
0
 

Author Comment

by:Duggie
ID: 17775137
myresult=Resource id #14
0
 

Author Comment

by:Duggie
ID: 17775220
Solved it, wasn't a problem with the Result at all. The ..some other code had another reference to the $myresult variable which I had put inside the while loop in error. The section $myresult was an update query which was producing the error message.
Move the code outside the while loop so the original $myresult is finished with and the code worked fine.

Only about a day to suss out my own error.
Thanks to Yuval for the response.

What should I do about the points since I solved the problem myself ?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 17992668
PAQed with points refunded (250)

Computer101
EE Admin
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question