punch_card_don has asked for the wisdom of the Perl Monks concerning the following question:
Is it my Perl. It is my SQL? Is it MySQL? Inquiring minds want to know.
I have a user's info table in a MySQL db. One of the columns - surprise surprise - is the phone number, 'phone'. It's declared as VARCHAR(20). Input comes from an html form. The phone number goes into a text input, imaginatively named 'phone', which, using cgi.pm, gets read into a hash of values, $form_values{'phone'}.
Here's the strange part: certain formats of phone number input result in the the last one, sometimes two characters being cut off in the db.
For example:
In the Perl script, the pertinent lines are:
The SQL always look well formed. The phone number input to the form always shows up in the sql-statement.$sql = "UPDATE users SET fname='".$form_values{'fname'}."', lname='".$form_values{'lname'}."', phone='".$form_values{'phone'}."' WHERE (contact_id = $form_values{'contact_id'}) "; print "<p>sql = $sql\n"; #execute $sth = $dbh->prepare($sql) or die("Could not prepare!" . $dbh->errstr) +; $sth->execute() or die("Could not execute!" . $dbh->errstr);
Holy weapons of mass destruction, Batman, what could be blowing up in this?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI/MySQL system cutting off UPDATE values.
by Joost (Canon) on Jan 31, 2008 at 20:54 UTC | |
|
Re: DBI/MySQL system cutting off UPDATE values.
by nedals (Deacon) on Jan 31, 2008 at 22:39 UTC | |
by punch_card_don (Curate) on Jan 31, 2008 at 23:08 UTC |