Page 1 of 1
Large variable error-medic!
Posted: Thu Oct 03, 2002 1:50 pm
by lawful_toad
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?
Posted: Thu Oct 03, 2002 2:40 pm
by rev
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.
Posted: Thu Oct 03, 2002 3:38 pm
by Takuma
Or you can just change it to LONGTEXT.
One problem with your code
Code: Select all
<?php
mail("email@address.org", "Form Title", "", $headers);
?>
Posted: Fri Oct 04, 2002 9:55 am
by lawful_toad
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.

Posted: Fri Oct 04, 2002 10:13 am
by Takuma
Posted: Fri Oct 04, 2002 10:16 am
by lawful_toad
A typo
mail("
address@domain.org", "DPR FORM", "", $headers);
Posted: Fri Oct 04, 2002 10:31 am
by Takuma
Can we see the code before and after it? It might be something to do with PHP itself...

Posted: Fri Oct 04, 2002 10:41 am
by lawful_toad
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);
}
}
?>
Posted: Fri Oct 04, 2002 11:34 am
by twigletmac
Could you cut the stuff in the PHP tags up a bit as it's causing the page to be very wide. Stuff in the [P H P] tags doesn't wordwrap so you have to be a bit careful as to how long lines are.
Mac
Posted: Fri Oct 04, 2002 12:28 pm
by lawful_toad
sry for wide page, should be fixed
Posted: Sat Oct 05, 2002 9:02 am
by jonsyd
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

.
Posted: Thu Oct 10, 2002 2:59 pm
by lawful_toad
I can set a variable equal to a 500 character string and send it with my just the variable and the mail code. I am using Post with the form. I'm really running out of ideas. You want me to try cutting the variable up and emailing the seperate parts?
Posted: Fri Oct 11, 2002 8:32 am
by jonsyd
Not exactly, I was suggesting you try mailing different blocks of text to eliminate sendmail quirks. If it handles a 500 char mail with no newline characters in it, then this is not your problem.
Posted: Fri Oct 11, 2002 1:01 pm
by lawful_toad
I don't know what else the problem could be. Like I said previously, I use the same mail code in about 15 other forms and it works fine.
The latest thing that it is doing is in the form, if I put a 500 character string in the textarea box and hit submit, it just times out now.