...

View Full Version : Line splitting into two



rfresh
09-25-2008, 07:25 AM
I have a script that gets called when I email to a specific email address. The email body contains PHP code and the script writes the text to my home folder. It's sort a replacement for using an FTP client as sometimes I don't have FTP access but I do have email.

So, I make what ever changes I need to, to the text and then email it in the body to this email address which calls my PHP script below and it processes the text.

Everything is working fine except a couple of the lines that get written out to the file get split into two lines instead of one line as the orginal is.

This is my PHP script that gets called when the email comes in:


#!/usr/local/bin/php
<?php
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd))
{
$email .= fgets($fd);
}
fclose($fd);

$lines = explode("\n", $email);

$result = count($lines);
for ($i = 0; $i < $result; $i++)
{
$php_ftp_code .= $lines[$i]."\n";
}

$php_file = "/home/juicyco/public_html/".$php_ftp_filename;
$php_handle = fopen($php_file,"w");
fwrite($php_handle, $php_ftp_code);
fclose($php_handle);
?>


The text I email:


<TR>
<TD width="268" valign=bottom>
<?php
$php_resultID = mysql_query("SELECT * FROM admin WHERE Id = '4'", php_linkID);
$php_row = mysql_fetch_object($php_resultID);
$php_photo_file = "photos/".$php_row->photo2_file;

mysql_close($php_linkID);

?>
<IMG SRC="<?php echo $php_photo_file ?>" WIDTH="268" HEIGHT="176" BORDER="0" ALT="">
</TD>
</TR>


How the text gets written to the server. Note the two locations where the lines have split - does anyone know why my code is doing this unwanted split?


<TR>
<TD width="268" valign=bottom>
<?php
$php_resultID = mysql_query("SELECT * FROM admin WHERE Id = '4'",
$php_linkID);
$php_row = mysql_fetch_object($php_resultID);
$php_photo_file = "photos/".$php_row->photo2_file;

mysql_close($php_linkID);

?>
<IMG SRC="<?php echo $php_photo_file ?>" WIDTH="268" HEIGHT="176"
BORDER="0" ALT="">
</TD>
</TR>

mlseim
09-25-2008, 02:06 PM
I'm thinking that when you email it, you're putting (pasting) into a textbox
on your email program that is smaller than the text, so the textbox is creating
a line break "wrapping" instead of keeping the lines intact.

When you submit the email, the program is taking the line feeds in your textbox literally.
If you look at the lines that were split, it looks to me like they have been cut at the
same spot (the same width).

See if there's an option in your email client to "wrap" text ... turn off wrapping.
(or the other way around ... can't remember which).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum