/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@DasherMar 29.2011 — I still use HTML-Kit for my editor, never had any problems with it.
Copy linkTweet thisAlerts:
@NoasITMar 29.2011 — 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.
Copy linkTweet thisAlerts:
@smithsterauthorMar 29.2011 — 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
Copy linkTweet thisAlerts:
@DerokorianMar 29.2011 — 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.
Copy linkTweet thisAlerts:
@criterion9Mar 29.2011 — 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.
Copy linkTweet thisAlerts:
@svidgenMar 29.2011 — 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 ...
Copy linkTweet thisAlerts:
@smithsterauthorMar 29.2011 — 
The cpanel file editor seems like the prime suspect to me
[/QUOTE]

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 ?
Copy linkTweet thisAlerts:
@tracknutMar 29.2011 — 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
Copy linkTweet thisAlerts:
@svidgenMar 29.2011 — 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.[/QUOTE]

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.[/QUOTE]

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.
Copy linkTweet thisAlerts:
@smithsterauthorMar 29.2011 — 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!!
×

Success!

Help @smithster spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...