All this code below used to work! I then changed troop to group and since then its not been inputing into the database! I've debugged and all the information is coming through, its just not going into my database.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
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 'group, name, tel, place, activity) VALUES ('11-7-2012','11-8-2012','swl7@gm' at line 1
INSERT INTO activities (datearriving, dateleaving, email, group, name, tel, place, activity) VALUES ('11-7-2012','11-8-2012','swl7@gmail.com','groupsev','swl7','0987654321','ash','Archery range')
The only thing I changed were the words troop to group then it started failing lol
Try quoting the column name with "back tick" quotes, so that MySQL knows it's an identifier and not the keyword GROUP:
Code:
`group`
(Or change the column name to something like "group_name" so that there can be no confusion.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
They are for different purposes. The back-quotes are for "identifiers": table names, column names, and such. Regular "straight" quotes are for string literals, so those will still be used around actual text/character values.
Code:
INSERT INTO `my_table` (
`col_1`,
`col_2`,
`col_3`
) VALUES (
1234, -- integer column
'This is a test.
It is only a test', -- text column
'fubar' -- varchar column
);
The back-quoting is optional when there is no name clashing with reserved words and the name itself does not have spaces or other normally invalid characters in it, but it never hurts to back-quote them, so many people just quote all identifiers for consistency.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks