rootKID 18 Posted November 21, 2017 Report Share Posted November 21, 2017 hey W3S! Been a while! Anyhow, i have a question regarding my SQL... not sure, since it's been a while. So i am running latest version of WinginX with PHP 7.1 and PhpMyAdmin latest version all... i tried to run this SQL, which usually works: SELECT p1_c_c_id AS id, p1_c_c_name AS name, p1_c_c_level AS level, p1_c_c_order AS order FROM plugin1_class_categories ORDER BY order ASC and i got the error below: Fatal error: Uncaught Error: Call to a member function fetch_assoc() on boolean in <path> Stack trace: #0 {main} thrown in <path> on line 131 so then i went nuts and went to the PhpMyAdmin sql builder and it builded this for me: SELECT `p1_c_c_id` AS `id`, `p1_c_c_name` AS `name`, `p1_c_c_level` AS `level`, `p1_c_c_order` AS `order` FROM `plugin1_class_categories` ORDER BY `p1_c_c_order` ASC and that works? Only difference is the plinges... the (')... why? The other one usually works also right? Or am i remembering wrong? Tried to read a little bit about it but gave no sence since it's been a while with everything hehe Well thanks if you can help me anyways! Thanks in advance! Quote Link to post Share on other sites
dsonesuk 913 Posted November 21, 2017 Report Share Posted November 21, 2017 I would imagine it would be "p1_c_c_order AS order" causing problem as ORDER is reserved for sorting in SQL, by using backticks it eliminates the conflict. Quote Link to post Share on other sites
rootKID 18 Posted November 21, 2017 Author Report Share Posted November 21, 2017 hmm... i tried to remove to ORDER from the SQL also but didn't work for some reason, which is why i'm kinda confused.. should be working. Or at least that is what i remember that it should :/... Quote Link to post Share on other sites
dsonesuk 913 Posted November 21, 2017 Report Share Posted November 21, 2017 (edited) 'order' or ORDER? 'order' is the problem, it is treated as SQL ORDER and in the wrong position, therefore an error is produced. even 'name' and 'level' are keywords, with as mentioned order being reserved https://dev.mysql.com/doc/refman/5.7/en/keywords.html#keywords-5-7-detailed-N Edited November 21, 2017 by dsonesuk Quote Link to post Share on other sites
justsomeguy 1,135 Posted November 21, 2017 Report Share Posted November 21, 2017 ORDER BY order You should have noticed that when you were writing the code, ORDER is obviously a reserved word. If you're going to use reserved words as identifiers then you need to surround them with backticks so that MySQL knows you are referring to an identifier instead of the reserved word. Quote Link to post Share on other sites
rootKID 18 Posted January 6, 2018 Author Report Share Posted January 6, 2018 ok fail i have fixed the problem haha Thx a lot guys! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.