GetDotted Domains

Viewing Thread:
"Hmmm...that's never happened before (PHP bug?)"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Fri 10/12/04 at 09:54
Regular
"Pouch Ape"
Posts: 14,499
I've set up a quick form and script that lets my client enter news articles, with a headline and content. Then you can select a news article to view and edit from a dropdown list, which embeds the data into an input box and textarea, for the headline and content respectively. But each time the data is sent through to the editing script, it adds a blank line to the end, even if the text is deleted right up to the last character. I'm using nl2br, which means that if I edit the script four times, I get 4 new lines and it upsets the content on the frontend.

I'm pretty sure it's something to do with the nl2br. But I'm also pretty sure that I've never had this problem before, and I've set this sort of system up numerous times. Is there some hidden little PHP bug that I don't know about yet? I can always solve it by using a function to take one character away from the string, but was wondering if it's a common occurance?
Fri 10/12/04 at 15:52
Regular
"Pouch Ape"
Posts: 14,499
Hurrah I got something right by accident!
Fri 10/12/04 at 15:49
Regular
"Devil in disguise"
Posts: 3,151
ereg_replace allows regulation expressions, str_replace is just straight substitution, could equally use str_replace instead in those lines I put. In fact you should really as its faster.
Fri 10/12/04 at 15:12
Regular
"Pouch Ape"
Posts: 14,499
What's the difference between ereg_replace and str_replace? Can't be bothered looking at PHP.net.
Fri 10/12/04 at 15:07
Regular
"Devil in disguise"
Posts: 3,151
Well I never use nl2br personally, so cant say too much. I dont think the behaviour is a bug, if it were you'd probably find it mentioned in the comments section of the php manual.
I can remember encountering this in the past, although that was because of me not filtering out \r. Try doing the conversion manually;

$string=ereg_replace("\n","
",$string);
$string=ereg_replace("\r","",$string);

Supposedly, thats all nl2br is anyway (well it leaves in the \n but just depends if you care about the raw html being formatted).
Fri 10/12/04 at 14:42
Regular
"Pouch Ape"
Posts: 14,499
Garin wrote:
> When you say it adds a blank line at the end, I presume you mean
> you've got an extra carriage return at the end. Is it a
> \n that you get extra of?

The
. It's easy enough to get rid of, but why in the first place?
Fri 10/12/04 at 14:41
Regular
"Devil in disguise"
Posts: 3,151
When you say it adds a blank line at the end, I presume you mean you've got an extra carriage return at the end. Is it a
or a \n that you get extra of?
Fri 10/12/04 at 09:54
Regular
"Pouch Ape"
Posts: 14,499
I've set up a quick form and script that lets my client enter news articles, with a headline and content. Then you can select a news article to view and edit from a dropdown list, which embeds the data into an input box and textarea, for the headline and content respectively. But each time the data is sent through to the editing script, it adds a blank line to the end, even if the text is deleted right up to the last character. I'm using nl2br, which means that if I edit the script four times, I get 4 new lines and it upsets the content on the frontend.

I'm pretty sure it's something to do with the nl2br. But I'm also pretty sure that I've never had this problem before, and I've set this sort of system up numerous times. Is there some hidden little PHP bug that I don't know about yet? I can always solve it by using a function to take one character away from the string, but was wondering if it's a common occurance?

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

The coolest ISP ever!
In my opinion, the ISP is the best I have ever used. They guarantee 'first time connection - everytime', which they have never let me down on.
Easy and free service!
I think it's fab that you provide an easy-to-follow service, and even better that it's free...!
Cerrie

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.