www.webdeveloper.com
Results 1 to 11 of 11

Thread: All PHP code suddenly on one line?!?!?

  1. #1
    Join Date
    Feb 2011
    Posts
    38

    Cool All PHP code suddenly on one line?!?!?

    I've seen this happen a few times and it's very frustrating when it happens especially if it's a large script. I find out about it when I visit the web page and there's an error on screen!

    I opened the php file in noteplad++ and every bit of the coding is on 1 major long line!! Has anyone else had this happen and do you know what causes it to happen?

    I have to spend hours now going through the one line, seperating each part onto its own lines again before the script will work.

    Hoping for a solution, or atleast the comfort of knowing I'm not alone in this situation!

    Smithster

  2. #2
    Join Date
    Jan 2006
    Location
    MN
    Posts
    440
    I still use HTML-Kit for my editor, never had any problems with it.

  3. #3
    Join Date
    Aug 2010
    Location
    Ohio
    Posts
    136
    I've never heard of such a thing, I use Komodo-Edit for all my work, never had a problem can even customize the size of tabs, auto indent, highlight your own way etc.

  4. #4
    Join Date
    Feb 2011
    Posts
    38
    Hi,

    I'm not blaming the editor at all, the particular web page was working fine not so long ago and I've been working on other pages since.

    Just looked at the file within cpanel's file editor. The file editor forces the script to go down the page anyway but on the very first line is this....

    <?phpinclude('header.php');?><script type="text/javascript">

    Straight away you can see the coding has been completely scrunched up and I don't understand what's caused that to happen.

    Smithster

  5. #5
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    I dont know the cause, but a solution would be to assign permissions to the folders with scripts that make them readonly so they can't be changed server side. Then you can give permissions to like you images/uploads/ folder (or whateva you need to be change via your scripts) Again not a reason for why it happened but something that can help prevent problems in the future.

  6. #6
    Join Date
    Jan 2009
    Posts
    3,346
    It sounds like you might be switching between MS and *nix line ending style OSes. I for 1 never under any circumstance edit a file on a production server. It is best practice to edit the files in a development environment and only move tested code to a production environment.

  7. #7
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    The cpanel file editor seems like the prime suspect to me ... I don't see any difference between a file using windows and unix newlines on my installation. You can check w/ the "who all characters" button in notepad++, of course ...
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  8. #8
    Join Date
    Feb 2011
    Posts
    38
    The cpanel file editor seems like the prime suspect to me
    Since I don't use the cPanel file editor, I can't see that being the cause for any changes. I mentioned cPanel's editor only because I used it to view the script after using notepad++'s built in ftp plugin to download the script for editing.

    It makes more sense to suggest that something happened to the file during ftp transmission from the local machine to the server. But I can't accept that as I know that noteplad++ and fileziller ftp client are very commonly used in web development and yet this problem I have had tonight, I don't see others complaining of it and I've suffered with it on more than one occasion.

    It is a rarity, but some of my scripts are 1000 lines of coding. The script in question this time was only around 200 lines but still a bulls ache having to fix it!

    I think there are 2 many possible causes for me to narrow it down and so I am without faith that I will find the answer

  9. #9
    Join Date
    Aug 2006
    Posts
    1,917
    Do you keep a local copy of your PHP files? Seems like if the error happened during transmission to the site (could it be the php file was uploaded in binary mode rather than ascii? I don't know if this would cause the problem), then you would still have your original local copy.

    Dave

  10. #10
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Quote Originally Posted by smithster View Post
    I mentioned cPanel's editor only because I used it to view the script after using notepad++'s built in ftp plugin to download the script for editing.
    Ah -- understood. This is a little confusing then:

    Straight away you can see the coding has been completely scrunched up and I don't understand what's caused that to happen.
    So, you download the file with notepad++, find that it's "scrunched", but then also find that it's "scrunched" on the server-side?

    If you suspect errors in transmission, try transferring all of your files in binary mode.
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  11. #11
    Join Date
    Feb 2011
    Posts
    38
    Most of my work and transferring is done via notepad++ which uses binary transfer mode as its default setting. It's only on the very odd occasion that I use filezilla since notepad++ has built in ftp. I have just checked the transfer mode setting in filezilla and it was set at auto so I've switched it to binary and hopefully (assuming that may have been the cause) I won't have anymore problems. Fingers crossed and touching wood!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles