Forums

custom code INSERT INTO a table fails due to special character

kwok 13 Mar, 2016
Hi Bob,

I have a INSERT INTO in custom code that throws a 1064 Syntax Error when the user entry form field contains string like "Let's go", "I'll do it". It is the apostrophy. What would you recommend to handle such scenario?

How does chronoform handle it during DB Save?

Thanks,
kwok
GreyHead 13 Mar, 2016
Hi kowk,

Either use the ChronoForms DB Save action, or fix your custom code so that the values are correctly quoted. See the MySQL docs here for some examples.

Bob
kwok 13 Mar, 2016
Hi Bob,

I was trying to explore INSERT TO in chronoform environment. If it works "flawlessly", I wouldn't need to create form fields for all columns of the target table.

Now I totally agree that DB Save is more superior.

Thanks,
kwok
GreyHead 14 Mar, 2016
Hi kwok,

You can use MySQL directly but then you have to get the syntax right. The ChronoForms + Joomla! methods require that the tables have a numeric auto-incremented primary key. If there is a valid key in the data then that record is updated, otherwise a new one is created - unless you use the Conditions box to over-ride that.

Bob
This topic is locked and no more replies can be posted.