Large variable error-medic!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lawful_toad
Forum Newbie
Posts: 12
Joined: Fri Sep 27, 2002 11:02 am
Location: collinsville, il

Large variable error-medic!

Post 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?
rev
Forum Commoner
Posts: 52
Joined: Wed Oct 02, 2002 3:58 pm
Location: Atlanta, GA

Post 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.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post 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); 
?>
lawful_toad
Forum Newbie
Posts: 12
Joined: Fri Sep 27, 2002 11:02 am
Location: collinsville, il

Post 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. :?:
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Code: Select all

<?php
""Form Title
?>
What's this?
lawful_toad
Forum Newbie
Posts: 12
Joined: Fri Sep 27, 2002 11:02 am
Location: collinsville, il

Post by lawful_toad »

A typo
mail("address@domain.org", "DPR FORM", "", $headers);
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Can we see the code before and after it? It might be something to do with PHP itself... :?
lawful_toad
Forum Newbie
Posts: 12
Joined: Fri Sep 27, 2002 11:02 am
Location: collinsville, il

Post 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> </td>

<td ></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> </td></tr><tr>

<td align=center>Data Processing & Committee Use</td></tr>

<tr><td> </td></tr></table><table width=80%><tr>
<td width=30% align=right><b>Date Recieved:</b></td><td width=50%>____________________</td></tr>
<tr><td> </td></tr>
<tr><td width=30% align=right><b>Committee Member's Initial:</b></td><td width=50%>____________
</td></tr>

<tr><td> </td></tr><tr><td width=30% align=right><b>Comments:</b></td><td width=50%> </td></tr></table>

<table width=80%>
<tr><td> </td></tr><tr><td width=30% align=right> </td>

<td width=50% align=left>____________________________________________________</td></tr>

<tr><td> </td></tr><tr><td width=30% align=right> </td><td width=50% align=left>
____________________________________________________________</td></tr>

<tr><td> </td></tr><tr><td width=30% align=right> </td><td width=50% align=left>

_______________________________________________________________________________</td></tr>

<tr><td> </td></tr><tr><td width=30% align=right> </td><td width=50% align=left>
_____________________________________________________________</td></tr>

<tr><td> </td></tr><tr><td width=30% align=right> </td><td width=50% align=left>

_________________________________________________________________</td></tr>

<tr><td> </td></tr><tr><td width=30% 

align=right> </td><td width=50% align=left>
_________________________________________________________________</td></tr></table>
<table width=80%><tr><td width=30% align=right> </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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
lawful_toad
Forum Newbie
Posts: 12
Joined: Fri Sep 27, 2002 11:02 am
Location: collinsville, il

Post by lawful_toad »

sry for wide page, should be fixed
User avatar
jonsyd
Forum Commoner
Posts: 36
Joined: Fri Sep 20, 2002 9:28 am
Location: Oxford, UK

Post 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 :) .
lawful_toad
Forum Newbie
Posts: 12
Joined: Fri Sep 27, 2002 11:02 am
Location: collinsville, il

Post 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?
User avatar
jonsyd
Forum Commoner
Posts: 36
Joined: Fri Sep 20, 2002 9:28 am
Location: Oxford, UK

Post 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.
lawful_toad
Forum Newbie
Posts: 12
Joined: Fri Sep 27, 2002 11:02 am
Location: collinsville, il

Post 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.
Post Reply