SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast owentech's Avatar
    Join Date
    Apr 2006
    Location
    Nairobi, Kenya
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Files Losing Format

    Hi,
    A client's web host seems to be removing whitespaces and line breaks in PHP files, thus affecting functionality

    or example
    PHP Code:
    <?php
    //start session
    session_start();
    include(
    'myfile.php');
    ?>
    becomes

    PHP Code:
    <?php//start sessionsession_start();include('myfile.php');?>
    Settings:
    Apache/2.2.6 (FreeBSD) mod_ssl/2.2.6 OpenSSL/0.9.8e DAV/2 PHP/5.2.5 with Suhosin-Patch

    What could be the problem?
    Life is too short to think small - John Mason
    What is any life if not the pursuit of a dream? - Vanilla Sky
    PHP Membership Script

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    How's your client getting the files onto the host? FTP? In binary or ascii mode? A file uploader in their hosting control panel? A file editor in the hosting control panel?

    The problem is more likely your client than some kind of code on the server changing the files.

  3. #3
    SitePoint Enthusiast owentech's Avatar
    Join Date
    Apr 2006
    Location
    Nairobi, Kenya
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I upload the files using CoreFTP in ASCII mode, just as I have done before.

    I tried Filezilla, with apparently the same result.
    Life is too short to think small - John Mason
    What is any life if not the pursuit of a dream? - Vanilla Sky
    PHP Membership Script

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2009
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please try uploading files in BINARY mode, it should be fine. Also configure FTP client to upload .php files as BINARY files ONLY.
    Daniel, Helpdesk Leader
    Hosting24.com Web Hosting - First class web hosting services.
    Reseller Hosting - Provide unlimited disk space and bandwidth

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,653
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    owen,

    While Hosting24's tactic may be successful, it's NOT the way to upload PHP files: Use ASCII mode.

    I'd first troubleshoot by personally uploading (in ASCII mode) any test.php file then "view" (downloading to your text editor) and comparing with what you uploaded. If it's not the same thing, then there's either a problem with your FTP apps OR your host is doing something very weird. Assuming that your FTP works fine elsewhere, contact your host and have them look at that immediately!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2009
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why should person upload .php files not in binary mode?
    Daniel, Helpdesk Leader
    Hosting24.com Web Hosting - First class web hosting services.
    Reseller Hosting - Provide unlimited disk space and bandwidth

  7. #7
    SitePoint Enthusiast owentech's Avatar
    Join Date
    Apr 2006
    Location
    Nairobi, Kenya
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.
    Let me try both tests and see
    Life is too short to think small - John Mason
    What is any life if not the pursuit of a dream? - Vanilla Sky
    PHP Membership Script

  8. #8
    SitePoint Enthusiast owentech's Avatar
    Join Date
    Apr 2006
    Location
    Nairobi, Kenya
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks people!

    I uploaded a test file with the default ASCII for php and lost the formatting.

    I removed php from the list of ASCII and switched to binary mode. I uploaded and the file was ok.

    I am also interested in knowing why I should not use binary for php or other text files.
    Life is too short to think small - John Mason
    What is any life if not the pursuit of a dream? - Vanilla Sky
    PHP Membership Script

  9. #9
    SitePoint Enthusiast owentech's Avatar
    Join Date
    Apr 2006
    Location
    Nairobi, Kenya
    Posts
    93
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried a different FTP client (Filezilla) with the same results.
    Uploading as ASCII is resulting in loss of formatting.
    Life is too short to think small - John Mason
    What is any life if not the pursuit of a dream? - Vanilla Sky
    PHP Membership Script


Bookmarks

Posting Permissions

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