Phone # field type

emmceegee 07 Mar, 2010
I am having trouble getting the phone # with a hyphen in it to write to the table when saving the form data. I have tried defining it in the table as both varchar and as decimal. As varchar it doesn't write at all, and as decimal it only writes the first three decimals. My testing suggests that this is because it doesn't like the hyphen that is common in phone #s here. If I enter the number without hyphens, it writes in both cases. However this is a problem as we are driving data into the form from our database, and the phone numbers mostly have the hyphens in them by default (i.e., 123-456-7890.) In some cases, thanks to our lovely DB, there are brackets in the numbers too, which doesn't work either.
It comes in the email no problem, but how can I define that field so that it writes no matter what character type or syntax is entered in that field? (I have not limited the field in the form in any way).
Thanks - great app.
GreyHead 07 Mar, 2010
Hi emmceegee,

ChronoForms doesn't correctly quote correctly before the database save is executed - this gives problems with using dashes in input names and in form names. I'm not sure that it usually gives problems with data saving though.

Are you sure that the db column is defined as text or varchar and isn't a numeric type?

emmceegee 07 Mar, 2010
Bob thanks for the prompt reply - didn't expect to hear from you today.
I have tried the field as types varchar, text and decimal. In all those cases, when I submit the form, it sends the email with all the data, and writes the record to the assigned table. When the phone number includes a hyphen or a bracket it will not write the phone number to the table. The slight exception is when the hyphen follows digits in the phone number, in which case it writes the digits prior to the offending character. As I mentioned, the unfortunate truth is that our wretched DB from which we are creating the PURLs that populate this form includes these characters in the phone numbers.
My understanding is that MySQL supports hyphens in varchar strings, although I am no expert. Is there anything I can do here short of recasting the DB?
Thanks again for your support - it is greatly appreciated.

GreyHead 08 Mar, 2010
Hi Martin,

There's something odd here. I checked some of my form tables and there doesn't appear to be any problem in saving data with dashes and brackets in text or varchar fields.

If you like to PM or email me the site URL and a superadmin login then I'll take a quick look - or alternatively send me a form backup and a backup of the DB table and I'll try them on a test site here.

emmceegee 08 Mar, 2010
Bob good day -

I have sent you the login details for the site via email.

The form I am having difficulty with is contactform_qr, and the table is newsletter_replies.

Thanks so much for taking a look at this Bob - very much appreciated.

Cheers -

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