JJohnsenDK Posted December 14, 2006 Share Posted December 14, 2006 HeyI looked through this a thoundens times but i just cant see what the error is.I get this error:[i]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by item_color' at line 1[/i]And im using this code[code]//Hent farver på tøjet $get_color = "SELECT item_color FROM store_item_color WHERE item_id = $item_id ORDER BY item_color"; $get_color_res = mysql_query($get_color) or die(mysql_error()); if (mysql_num_rows($get_color_res) > 0){ $display_block .= "<p><strong>Disse farver er tilgængelig:</strong></p>"; while($colors = mysql_fetch_array($get_color_res)){ $item_color = $colors['item_color']; $display_block .="$item_color<br>"; } }[/code]Anyone who can find the error? Link to comment https://forums.phpfreaks.com/topic/30669-resolced-why-do-i-get-this-error/ Share on other sites More sharing options...
zq29 Posted December 14, 2006 Share Posted December 14, 2006 You've missed out some single quotes in your query, try this:[code]SELECT `item_color` FROM `store_item_color` WHERE `item_id` = '$item_id' ORDER BY `item_color`[/code]I've enclosed your field/table names with backticks too, this is generally considered good practice. Link to comment https://forums.phpfreaks.com/topic/30669-resolced-why-do-i-get-this-error/#findComment-141309 Share on other sites More sharing options...
JJohnsenDK Posted December 14, 2006 Author Share Posted December 14, 2006 Yup, works... thanks mate :D Link to comment https://forums.phpfreaks.com/topic/30669-resolced-why-do-i-get-this-error/#findComment-141312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.