I run into this all the time. MySQL has crappy loading of reserved words. And when you come across it, the mysql error function is not good enough for you to know what is wrong.
The only thing you can do is change the column name. I accidentally used the "date, time and back" the other day. He pulled my hair when it dawned on me, DuHH !!! These are reserved databases.
You can wrap all quotation marks around it; it doesn't matter when it refers to the column name. Reserved Reserved!
It is usually customary to do a couple of things.
1) When creating tables: Separate the resource type with the resource name using the underscore. Example: xref_userMessages
This would mean it is a cross reference table for User messages.
2) Other examples of table names:
msg_Messages | sys_Settings | cli_Logins
Therefore, any other table associated with messages will be called msg _ ???, this not only keeps them in the phpMyadmin group, but also makes it easy to remember names.
3) When creating columns: never use reserved. Thus, there should always be 6 didgets for key columns. Example:
admkey | usrkey | msgkey | clikey grpkey
Obviously Admin Key | User Key | Message Key | Client Key | Group Key
So this means that the msg_Messages keys are "msgkey", and the xref table is xref_Messages, and its keys are xref_msgkey. Following this logic, you not only know what to call everything without even thinking about it, but you never come across any reserved words that do this.
4) Examples of column names:
dateInsert dateStart timeCreate admName admAddress admPhone admCell
As above, there is logic. Placing a target / owner and a noun / element together makes a name and again allows you to reserve words.
Last example:
Table: users_Admins users_Clients Key: admkey usrkey
Table: msg_Messages Columns: msgkey admkey usrkey msgRead msgMessage msgTitle
In this short example, I avoided 2 reserved words. Key and reading
In short, your problem is not reading the primary key. This is a problem with column names. MySQL sees that your code has syntax that has commands inappropriate. SELECT read ... or SELECT ... it doesnβt matter if you put quotation marks around it or not. MySQL basically sees ...
SELECT (SELECT, WHERE, FROM) FROM select, from, where
WHERE SELECT = WHERE & FROM = SELECT. hehehehehehehe
Putting another quote around this will not change the level of confusion that you just sent to MySQL.
Mixing my mistake and your mistake together looks like this ...
SELECT key, from, to, date FROM my_table WHERE key = '1';
// Same as ...
SELECT SELECT, SELECT, SELECT, SELECT FROM my_table WHERE SELECT = '1';
The first one you cannot say when looking at him is something wrong with him. Secondly, it is obvious that this is wrong and will not work. However, according to MySQL, they are SO.
MySQL gets this syntax so ... SELECT? You told me SELECT 5 times, you never told me what to choose. You get the FROM right, but then you ended up with a left hook telling you to choose something else, not only did you not tell me what to choose again, but you chose NULL = '1'; what it is? That is why when you make such errors, the error function does not even report what happened. There were so many errors that he cannot give you the error number, so he just stops.
So this means your syntax is like this
SELECT * FROM Bowlers WHERE SELECT = '1';
Sometimes I get upset and say: "I would like MySQL to be smarter than that!" But then I understand that I will have to trade keywords for a less important database. Each of these reserved words represents a word that does a lot more work with the database for me. When I started learning programming, I had to write my own text input routines, so I appreciate everything that MySQL does for me.