For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2005 > where is the error please









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author where is the error please
Dave

2005-08-17, 9:05 am

hello when i type it in my texterea

hello
how
are
you

I have it when I click in button ok
hello how are you

Please could you tell me why ? i dont have the skip line ;) thank you for
your help

This is the code

<form name="form1" action="apercu.php">
<textarea name="com" rows="9" cols="59"></textarea>
<input type="submit" name="ok" Value="ok">
</form>


in aperçu.php I have it

print($com);







Stefan Rybacki

2005-08-17, 9:05 am

Dave wrote:
> hello when i type it in my texterea
>
> hello
> how
> are
> you
>
> I have it when I click in button ok
> hello how are you
>
> Please could you tell me why ? i dont have the skip line ;) thank you for
> your help
>
> This is the code
>
> <form name="form1" action="apercu.php">
> <textarea name="com" rows="9" cols="59"></textarea>
> <input type="submit" name="ok" Value="ok">
> </form>
>
>
> in aperçu.php I have it
>
> print($com);
>

Its because in HTML new lines are represented by <br/> not by a normal CRLF or similar.
Look at your created HTML source. The new lines are there but not shown in the browser.
Just use print(nl2br($com)); to get what you want.

Regards
Stefan
Kimmo Laine

2005-08-17, 9:05 am

"Stefan Rybacki" <stefan.rybacki@gmx.net> wrote in message
news:3mgfu5F16ltuqU1@individual.net...
> Dave wrote:
> Its because in HTML new lines are represented by <br/> not by a normal
> CRLF or similar. Look at your created HTML source. The new lines are there
> but not shown in the browser. Just use print(nl2br($com)); to get what you
> want.
>



I'd also like to remind that it would be great if register_globals was
turned off and OP would use $_GET['com'] instead of $com, because that's
bettercoding practise. Read more at: http://fi2.php.net/register_globals

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com


c2c

2005-08-17, 9:05 am

"Dave" <topspam@topspam.us> pipotte et a dit :

> hello when i type it in my texterea
>
> hello
> how
> are
> you
>
> I have it when I click in button ok
> hello how are you
>
> Please could you tell me why ? i dont have the skip line ;) thank you for
> your help
>
> This is the code
>
> <form name="form1" action="apercu.php">
> <textarea name="com" rows="9" cols="59"></textarea>
> <input type="submit" name="ok" Value="ok">
> </form>
>
>
> in aperçu.php I have it
>
> print($com);
>


Dave, when the HTML is interpreted by your browser, NewLines are not
printed on screen, to obtain your expected result, you have to use :

print(nl2br($_REQUEST['com']));

(Please not that I user $_REQUEST['com'] instead of $com, consider
reading http://www.php.net/register_globals

--
Julien CROUZET aka c2c from Paris, France
jucrouzet _(a t)_ gmail.com
http://www.synten.com
Dave

2005-08-17, 5:00 pm

thank you it's ok now ;)


"Stefan Rybacki" <stefan.rybacki@gmx.net> a écrit dans le message de news:
3mgfu5F16ltuqU1@individual.net...
> Dave wrote:
> Its because in HTML new lines are represented by <br/> not by a normal
> CRLF or similar. Look at your created HTML source. The new lines are there
> but not shown in the browser. Just use print(nl2br($com)); to get what you
> want.
>
> Regards
> Stefan



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com