PDA

View Full Version : Email field not written to database properly


Anarchist
02-21-2005, 04:24 PM
Hello,

The script I am using is writing all but one fields to my database correctly, the email field however is not being written in it's entirety.

If I enter an email address of terry.jones@bt.com, the address written is something like terry.com instead.

I havent got a clue as to what could be causing this but here is the portion of code:

$dbh->do(
"INSERT INTO cust_order (Forename,Surname,House_Number,Street,Locality,Town,County,Postcode,Email) VALUES ('Graham','Smith','3','Doncaster Cresent','Parkfield','Stockton','Cleveland','RD45Ul5','caddf@vfvvb.net')",
undef,
(

$q->param('Forename'),
$q->param('Surname'),
$q->param('House_Number'),
$q->param('Street'),
$q->param('Locality'),
$q->param('Town'),
$q->param('County'),
$q->param('Postcode'),
$q->param('Email'),
)
);

$dbh->disconnect();


Cheers Anarchist

mlseim
02-21-2005, 04:39 PM
Try: 'caddf\@vfvvb.net'

Escape the @ with \ ..... \@
Because it's a special character.

Anarchist
02-21-2005, 04:46 PM
Thanks, but what about when I use this with a form how will I achieve that? I mean how will I get that 'caddf\@vfvvb.net'.

$dbh->do(
"INSERT INTO cust_order (Forename,Surname,House_Number,Street,Locality,Town,County,Postcode,Email) VALUES ('?','?','?',' ?','?','?','?','?','?')",
undef,
(

$q->param('Forename'),
$q->param('Surname'),
$q->param('House_Number'),
$q->param('Street'),
$q->param('Locality'),
$q->param('Town'),
$q->param('County'),
$q->param('Postcode'),
$q->param('Email'),
)
);

$dbh->disconnect();


Cheers

mlseim
02-21-2005, 05:14 PM
Have you tried it yet with a form?
I don't think you'll have a problem with that.

Let me know.

Anarchist
02-21-2005, 05:19 PM
I was going to complete the tables and scripts before writing the web, but I will write a quickie to test it. I just couldn't get my head around the form doing \ for me?

I'll try it and tell you if there is still a problem.

Thanks

andyede
02-22-2005, 08:23 AM
have you set your database up correctly? If the email isn't all being stored in the database sounds to me like you have defined the column with not enough characters for the email to fit. I'd say you need at least 50 chars for an email field maybe more. if you use varchar you won't have too much wasted memory.

Anarchist
02-22-2005, 11:48 AM
We'll the form works without a \ that was the puzzle for me. Andy I have the database set up as varchar [30] that wasn't the problem. Though thanks for your input.

It's good to see this working now, thanks all.

mlseim
02-22-2005, 02:39 PM
Anarchist .... F.Y.I.

You're using : "use CGI standard" or similar for handling the incoming
variables from your form. That "class" or "library", whatever it's called,
takes care of the \@ for you.

When you hard-coded it in your script, you needed to handle the
special character yourself.

Glad you got it to work. :thumbsup: