|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL syntax error
I am trying to use a prewritten function that submits to a database. (if it helps it is the private message service that this forum uses) Anyways, I'm useing a send_message() function that submits and entry to the database and Im getting this error...
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 '(mto,subject,message,mfrom) values(test1,Band confirmed,test1 - I'm not sure what's causeing the syntax error, any ideas? |
|
#2
|
||||
|
||||
|
RE: SQL syntax error
Can we see the whole query please?
|
|
#3
|
|||||||||||
|
|||||||||||
|
RE: SQL syntax error
php Code:
php Code:
php Code:
|
|
#4
|
|||
|
|||
|
RE: SQL syntax error
What happens when you echo the query to the screen?
|
|
#5
|
|||||
|
|||||
|
RE: SQL syntax error
Try modyfying the SQL string in the function...
php Code:
If you look at it closely there was a space missing after 'values' |
|
#6
|
||||||
|
||||||
|
RE: SQL syntax error
The above was just a suggestion for you to try out though might not solve your problem..
Quote:
Did u consider doing this?? To do this just add this line to the function.. php Code:
|
|
#7
|
|||
|
|||
|
RE: SQL syntax error
The output from
echo "INSERT INTO $table ($columns) values ($values)"; is INSERT INTO (mto,subject,message,mfrom) values ('test1','Band confirmed','test1 - You have just been confirmed as a bandmember of Test Band Two . You now have full access to edit the band's information. Enjoy. - MidwestSka.com','MidwestSka.org') Everything seems to be in order there, I think... |
|
#8
|
|||
|
|||
|
RE: SQL syntax error
Quote:
Yep.. Everything seems to be ok except that the field value that you are trying to insert seem to be generating the error.. $message contains a string that has a single quote in it.. To solve this you can use addslashes() function. Or by adding back slashes manually.. |
|
#9
|
|||
|
|||
|
RE: SQL syntax error
Quote:
I don't see no table name... |
|
#10
|
|||
|
|||
|
RE: SQL syntax error
Maybe this is where you went wrong. Did you forget to use single quotes in $config array around the element name? That will cause not to pass the value of tablename to your db_insert() function.
I mean do like this: instead of... |
|
#11
|
|||
|
|||
|
RE: SQL syntax error
I don't know if this was solved but I think that the problem is on the Insert statement:
INSERT INTO (mto,subject,message,mfrom) values ('test1','Band confirmed','test1 - You have just been confirmed as a bandmember of Test Band Two . You now have full access to edit the band's information. Enjoy. - MidwestSka.com','MidwestSka.org') Notice that single quotes are ok excepto that you have a "band's" in the middles and when you run that SQL the is like the string finish on the word "band". Try to replace the "band's" word with something similar "band`s". |
|
#12
|
|||
|