Large variable error-medic!
Moderator: General Moderators
-
lawful_toad
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 27, 2002 11:02 am
- Location: collinsville, il
Large variable error-medic!
I have a form. This form has a description textarea box. Do to the purpose of this textarea input, the resulting $description variables could be huge(a couple paragraphs). When completed my program submits it to the database and sends out an html embedded email to a user. If the $description variable is larger than one paragraph or so(# of chars seems to differ from time to time) and the form is submitted I get a 'Failed to send' error on the line where my mail code is.
mail("email@address.org", ""Form Title, "", $headers);
So!
I could not find anywhere that talked about a max variable length. Is there one? and if so how should I go about dealing with this?
mail("email@address.org", ""Form Title, "", $headers);
So!
I could not find anywhere that talked about a max variable length. Is there one? and if so how should I go about dealing with this?
I doubt it's a max variable length, my first inclination is to think that your problem resides in your DB table structure. If it is a simple VARCHAR(255) column, then of course only 255 characters make the cut. If this is the case, try altering the column type to TEXT from VARCHAR.
Also, make sure the form method is POST not GET.
Also, make sure the form method is POST not GET.
Or you can just change it to LONGTEXT.
One problem with your code
One problem with your code
Code: Select all
<?php
mail("email@address.org", "Form Title", "", $headers);
?>-
lawful_toad
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 27, 2002 11:02 am
- Location: collinsville, il
Thanks for the responses, sorry I didn't give more info. It's not a database problem. Aside from the insert query being commented out, mssql will simply just cut off the information without throwing errors. But like I said, I ruled out the insert query by taking it out. I use the same mail code on 20 other forms and all work fine, but I believe this is the only form that allows for such a large amount of characters. I don't have a clue what this problem is about. 
Code: Select all
<?php
""Form Title
?>-
lawful_toad
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 27, 2002 11:02 am
- Location: collinsville, il
A typo
mail("address@domain.org", "DPR FORM", "", $headers);
mail("address@domain.org", "DPR FORM", "", $headers);
-
lawful_toad
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 27, 2002 11:02 am
- Location: collinsville, il
sure. above this code is form validation stuff, shouldn't matter much and below this section in my program is the actual html for the form. this part is what creates the mail message
Code: Select all
<?php
$date = date("M d Y, g:i a");
//this is the body of the html embedded email
$data = "<html><head><style type=text/css>TD {font-size: 10pt}</style></head>
<body><b><center>Data Processing Request Form
Results<BR></b></center>
<table width=80><form><tr><td>&nbsp;</td>
<td&nbsp;></td></tr><tr><td width=30% align=right><b>Requested By:</b></td>
<td width=50%>$requested_by</td></tr>
<td width=30% align=right><b>Department:</b></td><td width=50%>$department</td></tr>
<tr><td width=30% align=right><b>Description:</b></td>
<td width=50%>$desc1$desc2@$desc3@$desc4</td></tr><tr>
<td width=30% align=right><b>Date Desired:</b></td><td width=50%
>$desired</td></tr>
<tr><td width=30% align=right><b>Date Critical:</b></td><td width=50%>$critical</td></tr></table>
<table width=80%><tr><td>&nbsp;</td></tr><tr>
<td align=center>Data Processing & Committee Use</td></tr>
<tr><td>&nbsp;</td></tr></table><table width=80%><tr>
<td width=30% align=right><b>Date Recieved:</b></td><td width=50%>____________________</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td width=30% align=right><b>Committee Member's Initial:</b></td><td width=50%>____________
</td></tr>
<tr><td>&nbsp;</td></tr><tr><td width=30% align=right><b>Comments:</b></td><td width=50%>&nbsp;</td></tr></table>
<table width=80%>
<tr><td>&nbsp;</td></tr><tr><td width=30% align=right>&nbsp;</td>
<td width=50% align=left>____________________________________________________</td></tr>
<tr><td>&nbsp;</td></tr><tr><td width=30% align=right>&nbsp;</td><td width=50% align=left>
____________________________________________________________</td></tr>
<tr><td>&nbsp;</td></tr><tr><td width=30% align=right>&nbsp;</td><td width=50% align=left>
_______________________________________________________________________________</td></tr>
<tr><td>&nbsp;</td></tr><tr><td width=30% align=right>&nbsp;</td><td width=50% align=left>
_____________________________________________________________</td></tr>
<tr><td>&nbsp;</td></tr><tr><td width=30% align=right>&nbsp;</td><td width=50% align=left>
_________________________________________________________________</td></tr>
<tr><td>&nbsp;</td></tr><tr><td width=30%
align=right>&nbsp;</td><td width=50% align=left>
_________________________________________________________________</td></tr></table>
<table width=80%><tr><td width=30% align=right>&nbsp;</td><td width=50%><font size=1>SCU 9003
07/31/2002</font></td></tr></table></body></html>";
//add From: header
$headers = "From: webmaster@domain.org\r\n";
//mime version
$headers .= "MIME-Version: 1.0\r\n";
//unique boundary
$boundary = uniqid("iduniq");
//tell client this e-mail contains alt versions
$headers .= "Content-Type: multipart/alternative" .
"; boundary = $boundary\r\n\r\n";
//message for mimeless
$headers .= "This is a MIME encoded message.\r\n\r\n";
//plain text
$headers .= "--$boundary\r\n" .
"Content-Type: text/plain; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode("This is the plain text version!"));
//html version
$headers .= "--$boundary\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n" .
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($data));
//send
mail("myemail@ispostedonprofile.org", "DPR FORM", "", $headers);
}
}
?>
Last edited by lawful_toad on Fri Oct 04, 2002 12:28 pm, edited 2 times in total.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
lawful_toad
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 27, 2002 11:02 am
- Location: collinsville, il
Just a couple of thoughts:
Are you using POST for the form? Not sure what it is, but there's a limit for the amount of data sent with GET requests.
Sendmail is a pain in the ass. It never seems to work the same from one system to another. Forget all the form stuff and just test the mail delivery with different blocks of text.
I kept running into a problem with it truncating long lines of text (~200 characters without a newline), so big paragraphs in email messages get chopped. This could be the same problem, try inserting newlines into your HTML version $data at appropriate places (eg. after any </tag>) and see what happens
.
Are you using POST for the form? Not sure what it is, but there's a limit for the amount of data sent with GET requests.
Sendmail is a pain in the ass. It never seems to work the same from one system to another. Forget all the form stuff and just test the mail delivery with different blocks of text.
I kept running into a problem with it truncating long lines of text (~200 characters without a newline), so big paragraphs in email messages get chopped. This could be the same problem, try inserting newlines into your HTML version $data at appropriate places (eg. after any </tag>) and see what happens
-
lawful_toad
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 27, 2002 11:02 am
- Location: collinsville, il
-
lawful_toad
- Forum Newbie
- Posts: 12
- Joined: Fri Sep 27, 2002 11:02 am
- Location: collinsville, il