rootKID Posted November 21, 2017 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! Link to comment Share on other sites More sharing options...
dsonesuk Posted November 21, 2017 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. Link to comment Share on other sites More sharing options...
rootKID Posted November 21, 2017 Author 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 :/... Link to comment Share on other sites More sharing options...
dsonesuk Posted November 21, 2017 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted November 21, 2017 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. Link to comment Share on other sites More sharing options...
rootKID Posted January 6, 2018 Author Share Posted January 6, 2018 ok fail i have fixed the problem haha Thx a lot guys! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now