Duggie
asked on
supplied argument is not a valid MySQL result resource
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/t ests/fanta syleague.p hp on line 95
This has been bugging me for ages know am getting a bit sick, please help
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($
{
...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
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/t
This has been bugging me for ages know am getting a bit sick, please help
ASKER
myresult=Resource id #14
ASKER
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 ?
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 ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
echo "myresult=".$myresult;
check to see what it contains...
-=Yuval=-