Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts

    Line splitting into two

    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:
    PHP Code:
    #!/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:
    PHP Code:
    <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?
    PHP Code:
    <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>
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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).

  • Users who have thanked mlseim for this post:

    rfresh (09-26-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •