If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

What I am doing wrong?

02-24-2013, 06:07 AM

Hi, trying to update another table after saving a record in a form. I am receiving this error:

Error

Close

Error while accessing the database:
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 'Date = 2013-02-20 , Encounter = '234234234', Patient Name = 'Test Any One' WHERE' at line 1

What I useually do is to break down the sql into one statement. This way the statement is more easy to read. If you set the debugoption in application menu then each sql statement is printed so you can see what sql statement is generated and why it's probabely wrong. I suspect that in your case (if you are using mysql) you have formatted the date wrong, afaik it needs quotes. And entry date with a space in the middle might give trouble. I always advise to use an underscore like entry_date. If you insist on using speces you need 'backquotes' to enclose the fieldname.

Comment

Hi. One of the first things I would do is to get the sql statement you are creating with your code - the one that is getting created with your syntax and variables - in this case $update_sql, and test it.

This is what I do. Create a log file and dump the $update_sql to it before you actually use it.

Created a suubfolder under your project called /mylog/ - the code below can be inserted into your SC events as many times as you want for logging test info. very handy when you can't get a clear place to echo or output variables to the screen.