Jump to content

also mysql_fetch_array issues here :p


surion

Recommended Posts

i got a very nice looking, quiet big sql statement (with subqueries n stuf) wich works perfect if i check it in phpmyadmin, but from the moment i put it in my phpcode, like this:

 

$results = mysql_query($sql); //$sql contains the sqlstatement
while($results_array = mysql_fetch_array($results))
{
echo $results_array['idcolltool'];
}

 

it woun't work anymore, i get next commonly viewed error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

/.../....php on line 85 (line 85 is the one with the while)

 

all names of columns and tables are checked & doublechecked on caps n stuf and are correct.

when i put @ before mysql_fetch_array the error is gone but i get no results anymore,...

any suggestions?

i realy don't understand what i can be doing wrong since it works fine with phpmyadmin,...

Link to comment
https://forums.phpfreaks.com/topic/41278-also-mysql_fetch_array-issues-here-p/
Share on other sites

It doesn't help when you don't provide the query for us, because that is most likely the proble. Are you posting the query into PHPMYADMIN as it is generated in your script? Or, are you trying to rebuild the query that runs in PHPMYADMIN? You should ALWAYS have error handling in your scripts. Change your first line to this:

 

$results = mysql_query($sql) or die ("Query:<br>".$sql."<br>Error:<br>".mysql_error());

do a:

 

echo '<br>';
echo $sql;
echo '<br>';

 

then copy and paste this text from the web page into mysqladmin and run it. Does this work?

 

monk.e.boy

 

that is what i did, and it worked perfect in phpmyadmin, anywayz, problem got solved, one of the other programmers here was smart enough to open another connection to another database and not close it again, somewhere before my code came, no wonder it didn't work, but thx anywayz for trying to help me (and sry for my bad english)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.