Closed Thread Icon

Topic awaiting preservation: Hard Enter Pages that link to <a href="https://ozoneasylum.com/backlink?for=12686" title="Pages that link to Topic awaiting preservation: Hard Enter" rel="nofollow" >Topic awaiting preservation: Hard Enter\

 
Author Thread
Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 04-08-2003 22:06

ok, i've got a guestbook,

its flat file,
I put the file into an array line by line, using file()
I then explode each line, the problem is, if a user press ENTER it will go to the next line in the flatfile. causing thr script to think its a new eentry and create a new post and it will just geenraly mess up the script,
I've tried looking up ways to check for \n or I think its HEX 0A but I cant come up with anything, naybe im not looking in the right places...

but yet agian any help would be greatlly appreciated as usual with my questiosns

Thanks
Trigger

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-08-2003 22:31

Alright first check out this thread
http://www.ozoneasylum.com/Forum12/HTML/001335.html

There's some things in there that might help
Second what you may want to do is just run a replace
<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>
$data = ereg_replace("(\r\n

Kriek
Maniac (V) Inmate

From: Florida
Insane since: Jul 2001

posted posted 04-09-2003 03:33

When working with file() in MOST cases trim() will do you for carriage returns "\n" and new lines "\n"

__________________

Kriek says '[SYSTEMWIDE_MESSAGE] PHP Meetup'
What we do is never understood; only praised and blamed

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 04-09-2003 09:35

argh.
just use nl2br() on the user's date, will convert all newlines into <br>s. Just be sure to filter the html out before you call nl2br().

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-09-2003 17:42

Actually that won't work. nl2br only inserts the break tags it doesn't remove the newline so he'd still have the same problem.



.:[ Never resist a perfect moment ]:.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 04-09-2003 19:01

actually, bitdamaged, you're right!
Always assumed that thing did what it said on the label (turn newlines into <br>s), and not that it would leave the darned things in.
still, I would not use the ereg_replace, but a simpler (and faster) string replace:

$data = str_replace(array("\n","\r\n","\r"),'<br />',$data)

Trigger
Paranoid (IV) Inmate

From:
Insane since: Jun 2002

posted posted 04-10-2003 17:26

Ok next question , i havent got \n or anything in the file but it goes to a new line... would you say the \n is invisble? becaus all's I have in my file is

<BLOCKQUOTE><FONT face="Verdana, Arial">quote:</font><HR>
Trigger

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-10-2003 17:47

you won't see a \n or \r the slash makes these escape characters for characters you can't see

this:
<BLOCKQUOTE><FONT face="Verdana, Arial">quote:</font><HR>
Trigger

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 04-10-2003 21:16

Depending on what editor you work in you might have a setting in the preferences to view hidden characters. If so, select it and you will see all the space and returns and what not. It's helped me more than once in figuring out why my code wasn't doing what I expected.

-Butcher-

« BackwardsOnwards »

Show Forum Drop Down Menu