DJ Unique Posted March 19, 2008 Share Posted March 19, 2008 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 More sharing options...
trq Posted March 19, 2008 Share Posted March 19, 2008 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? Link to comment https://forums.phpfreaks.com/topic/96886-mysql_fetch_array-not-working/#findComment-495826 Share on other sites More sharing options...
DJ Unique Posted March 19, 2008 Author Share Posted March 19, 2008 Hi, thanks for the reply, when I put in your suggested code I get the following: Illegal mix of collations for operation 'case' So is my SQL incorrect? Link to comment https://forums.phpfreaks.com/topic/96886-mysql_fetch_array-not-working/#findComment-495829 Share on other sites More sharing options...
trq Posted March 19, 2008 Share Posted March 19, 2008 So is my SQL incorrect? It would appear so. Ive never used any such statements, maybe post your query in the mysql board. Link to comment https://forums.phpfreaks.com/topic/96886-mysql_fetch_array-not-working/#findComment-495830 Share on other sites More sharing options...
DJ Unique Posted March 19, 2008 Author Share Posted March 19, 2008 Great thanks - I will post in the mysql section. Thanks for your help... Link to comment https://forums.phpfreaks.com/topic/96886-mysql_fetch_array-not-working/#findComment-495834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.