Jump to content

mysql_fetch_array not working!!


DJ Unique

Recommended Posts

Hi,

 

I'm trying to do the following:

 

$sql = mysql_query("select * 
from new_handset_network_variant 
where New_Handset_Network_Variant_Progress != 'Complete' and New_Handset_Network_Variant_Progress != 'Cancelled'
order by 
case New_Handset_Network_Variant_Priority
when	'High' then 1
when	'Normal' then 2
when	'Low' then 3
end");

$result = mysql_fetch_array($sql);

 

I get the following error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /web/stock/webmaster/ticket_overview2.php on line 15

 

The SQL query is 100% working and I can run it in SQL yog fine. Has anyone got any ideas? If I take the 'case function' out, it all works ok.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/96886-mysql_fetch_array-not-working/
Share on other sites

I'm not sure what SQL yog is, but that query definately doesn't look like it will work in mysql. You should at least check your query succeeded prior to calling mysql_fetch_assoc().

 

Try...

 

if ($sql) {
  if (mysql_num_rows($sql)) {
    $result = mysql_fetch_array($sql);
  }
} else {
  echo mysql_error();
}

 

What do you get?

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.