Simple Insert issue |
[eluser]ericsodt[/eluser]
Why is it that my code will only insert into the database when I used the following: Code: $insertData = array( However when I do it this way it doesnt work: Code: $insertData = array( Is there a way of fixing this or is this how you have to use db->insert ??
[eluser]Alex007[/eluser]
Does it give an error message when it "doesn't work" ? What does it say ?
[eluser]ericsodt[/eluser]
The standard mySQL error message saying there is an error in the syntax and to consult the manual
[eluser]deviant[/eluser]
EVENT is a keyword in MySQL, either name your table something else or you'll have to use the funny quotation marks or whatever they are.
[eluser]Michael Wales[/eluser]
Yeah - I think it's only the INSERT statement causing the issue, not all of the variables within your array. So, this should work: Code: $insertData = array(
[eluser]Alex007[/eluser]
[quote author="deviant" date="1190407404"]EVENT is a keyword in MySQL, either name your table something else or you'll have to use the funny quotation marks or whatever they are.[/quote] This is what I tought first, but I can't find it in the MySQL Reserver Keywords list... http://dev.mysql.com/doc/refman/5.0/en/r...words.html http://dev.mysql.com/doc/refman/4.1/en/r...words.html But I still agree with you, the funny quotes around the table name should be enough.
[eluser]ericsodt[/eluser]
Thanks for the replies guys... but I still need the "`" around all attributes otherwise it doesnt work. Below is a some sample code I wrote Code: $insertData = array( If the "`" are not in the code then both inserts and updates do not work correctly... also if you can think of another way to update when an insert fail, could you let me know. thx ![]()
[eluser]deviant[/eluser]
Well, you have also managed to choose another MySQL keyword: DESC :-) |
Welcome Guest, Not a member yet? Register Sign In |