Re: [PHP] Carriage Returns

2009-11-08 Thread Eddie Drapkin
On Sun, Nov 8, 2009 at 11:40 AM, John List johnl...@gulfbridge.net wrote:
 Dan Shirah wrote:

 Hello all,

 Basically I have a form with a textarea.  The user can enter up to 5,000
 characters in this text area.

 If the user just types text like: This is a test.

 And saves it, there's no problem.

 However if the user types:

 This

 Is

 A

 Test

 And saves it, the insert bombs.

 I've tried using nl2br($text) and str_replace(\r,#CR,$text) to convert
 the carriage returns, but it still crashes.

 I'm using an informix database and the column is: my_text    CHAR(5000)

 Any ideas why it crashes any time there is a carriage return in the text
 area?

 Thanks,
 Dan

 João Cândido de Souza Neto wrote:

 Are you using nl2br to convert before recording or after?



 This is probably an Informix problem or a problem with your interface to
 Informix. (I say that because I store textarea data with embedded newlines
 all the time in MySQL using the PHP mysql_ functions.)

 What interface are you using? ODBC?

 What errors do you get from Informix when it bombs?

 I'm guessing an embedded CR or LF character is breaking something as it's
 being passed to Informix. As João implies, if you really are changing these
 to break tags, you shouldn't have a problem. So you might try outputting the
 results of your conversion to your PHP error log before you pass it to
 Informix.

 You may find more help on an Informix list.

 John








 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


It's probably worthwhile to note that nl2br does NOT replace \n and/or
\r with br / but rather puts a br / before the newline
character(s).  Try str_replace(\r, '', $post_field).

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Carriage Returns

2009-11-08 Thread John List

Dan Shirah wrote:

Hello all,

Basically I have a form with a textarea.  The user can enter up to 5,000
characters in this text area.

If the user just types text like: This is a test.

And saves it, there's no problem.

However if the user types:

This

Is

A

Test

And saves it, the insert bombs.

I've tried using nl2br($text) and str_replace(\r,#CR,$text) to convert
the carriage returns, but it still crashes.

I'm using an informix database and the column is: my_textCHAR(5000)

Any ideas why it crashes any time there is a carriage return in the text
area?

Thanks,
Dan

João Cândido de Souza Neto wrote:

Are you using nl2br to convert before recording or after?

  


This is probably an Informix problem or a problem with your interface to 
Informix. (I say that because I store textarea data with embedded 
newlines all the time in MySQL using the PHP mysql_ functions.)


What interface are you using? ODBC?

What errors do you get from Informix when it bombs?

I'm guessing an embedded CR or LF character is breaking something as 
it's being passed to Informix. As João implies, if you really are 
changing these to break tags, you shouldn't have a problem. So you might 
try outputting the results of your conversion to your PHP error log 
before you pass it to Informix.


You may find more help on an Informix list.

John








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Carriage Returns

2009-11-08 Thread Nathan Rixham
Dan Shirah wrote:
 My guess is that you are getting an SQL error returned to you.  What does
 that
 say?  Is it talking about a broken SQL statement?

 Also, an example of the actual insert statement with example data would be
 helpful.



 
 I'm getting the generic error message: Prepare fails (E [SQLSTATE=IX 000
 SQLCODE=-282])
 
 My insert statement when echo'd out using print_r($insert) is nothing
 complex.
 
 INSERT INTO my_table VALUES (0, 'This is my text. When I use carriage
 returns it breaks. I am not sure why.')
 

informix doesn't allow new lines in sql strings; unless you enable the
ALLOW_NEWLINE setting on the server.

to remove newlines I'd suggest stripping all vertical space and
replacing it with spaces, then stripping down the excess horizontal
space.. something like

function strip_newlines( $string ) {
  $string = preg_replace( '/\v/' , ' ' , $string );
  $string = preg_replace( '/\h\h+/' , ' ' , $string );
  return $string;
}

$sql = strip_newlines( $sql );

regards,

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] carriage returns in php mailer

2005-05-12 Thread Ross
Hello,

http://scottishsocialnetworks.org/mailer.phps

I have a php mailer that takes in some text from a text box and puts in in 
an email. The problem is the body text is assigned to a variable to be put 
in the email but it does not pick up the returns.

How do i do this??


R. 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] carriage returns in php mailer

2005-05-12 Thread Richard Lynch
On Thu, May 12, 2005 2:40 am, Ross said:
 http://scottishsocialnetworks.org/mailer.phps

 I have a php mailer that takes in some text from a text box and puts in in
 an email. The problem is the body text is assigned to a variable to be put
 in the email but it does not pick up the returns.

The returns could come from a Windows browser (\r\n) or a Mac browser (\r)
or a Linux browser (\n)

You first need to get them to all be the same:

$body = str_replace(\r\n, \n, $body);
$body = str_replace(\r, \n, $body);
//Note that the order of the two statements is crucial

//You now have all Linux (\n) newlines.

If you are using Linux for your outgoing mail server, you are done.

If you are using Windows for your mail server, you probably need \r\n for
outgoing email:
$body = str_replace(\n, \r\n, $body);

If you are using Mac, you probably need \r:
$body = str_replace(\n, \r, $body);


Aside:
Some days I just wanna shoot the guys who made up these different newline
formats...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] carriage returns using error_log?

2005-03-21 Thread Richard Lynch
 Heh... no, I was already using double quotes. I also tried using actual
 carriage returns in the string, that didn't work either.

 Is error_log simply incapable of obeying carriage returns within the
 error string?

It works for me, but if it's not working for you...

function my_error_log($text){
  $lines = explode(\n);
  while (list(, $line) = each($lines)) error_log($line);
}

[shrug]

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] carriage returns using error_log?

2005-03-20 Thread Kurt Yoder
Is there any way to tell error_log to keep the newline characters? I am 
outputting error messages to the error log so I can look at detailed 
status information at the time of the error. However, if I put \n in 
the error message, it is treated literally by error_log and I see \n 
in the log message.

--
Kurt Yoder
http://yoderhome.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] carriage returns using error_log?

2005-03-20 Thread Chris Shiflett
Kurt Yoder wrote:
Is there any way to tell error_log to keep the newline characters? I am
outputting error messages to the error log so I can look at detailed
status information at the time of the error. However, if I put \n in the
error message, it is treated literally by error_log and I see \n in
the log message.
Try using double quotes instead of single quotes.
Hope that helps.
Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] carriage returns using error_log?

2005-03-20 Thread Kurt Yoder
On Mar 20, 2005, at 4:15 PM, Chris Shiflett wrote:
Kurt Yoder wrote:
Is there any way to tell error_log to keep the newline characters? I 
am
outputting error messages to the error log so I can look at detailed
status information at the time of the error. However, if I put \n in 
the
error message, it is treated literally by error_log and I see \n in
the log message.
Try using double quotes instead of single quotes.
Hope that helps.
Chris
Heh... no, I was already using double quotes. I also tried using actual 
carriage returns in the string, that didn't work either.

Is error_log simply incapable of obeying carriage returns within the 
error string?

--
Kurt Yoder
http://yoderhome.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] carriage returns using error_log?

2005-03-20 Thread Forest Liu
I prefer purpose it's the design concept in PHP error log.
If I would design a system containing error msg displaying. I would
also just simplly ignore the carriage returns character which the
programer passes to my system, in order to keep graceful in sight.


On Sun, 20 Mar 2005 21:50:09 -0500, Kurt Yoder [EMAIL PROTECTED] wrote:
 
 On Mar 20, 2005, at 4:15 PM, Chris Shiflett wrote:
 
  Kurt Yoder wrote:
  Is there any way to tell error_log to keep the newline characters? I
  am
  outputting error messages to the error log so I can look at detailed
  status information at the time of the error. However, if I put \n in
  the
  error message, it is treated literally by error_log and I see \n in
  the log message.
 
  Try using double quotes instead of single quotes.
 
  Hope that helps.
 
  Chris
 
 Heh... no, I was already using double quotes. I also tried using actual
 carriage returns in the string, that didn't work either.
 
 Is error_log simply incapable of obeying carriage returns within the
 error string?
 
 --
 
 Kurt Yoder
 http://yoderhome.com
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
   Sincerely,
 Forest Liu()

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] carriage returns using error_log?

2005-03-20 Thread Chris Shiflett
Kurt Yoder wrote:
Heh... no, I was already using double quotes. I also tried using actual
carriage returns in the string, that didn't work either.
Is error_log simply incapable of obeying carriage returns within the
error string?
No, I've used error_log() plenty, and I've never had a problem. Can you 
show us a specific example that would let us reproduce the problem locally?

Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Carriage returns in e-mail

2003-03-21 Thread Liam Gibbs
I think I might have had this problem a long time ago, but it wasn't resolved, because 
here it is again. My carriage returns (\r\n) aren't getting e-mailed.

I have some text:
The quick brown fox\r\n\r\n
jumped over the whateverwhateverwhatever\r\n\r\n
yadda yadda yadda.

I want to create double-spacing between paragraphs. This works out fine onsite (I've 
seen the output, and it does the proper double-spacing). However, when I e-mail it, 
it's all crunched down into single-spacing, so everything is all jumbled together and 
crowded.

Anyone have any idea why it's doing this?


[PHP] Carriage Returns in Text Fields

2002-09-03 Thread RoyW

I have a script which takes a memo field and stuffs it into a mediumtext
column of a MySQL table.

When I spit out the contents of the field, the carriage returns are no
longer there... how do I maintain the integrity of the paragraphs in text
fields?

Thanks




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Carriage Returns in Text Fields

2002-09-03 Thread Ryan A

Hey,
I myself am a newbie to PHP,
but I believe what you are looking for is the nl2br() functionI presume
you are outputting html.
Hope that helped.
Cheers,
-Ryan.

- Original Message -
From: RoyW [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 03, 2002 12:42 PM
Subject: [PHP] Carriage Returns in Text Fields


 I have a script which takes a memo field and stuffs it into a mediumtext
 column of a MySQL table.

 When I spit out the contents of the field, the carriage returns are no
 longer there... how do I maintain the integrity of the paragraphs in text
 fields?

 Thanks




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] carriage returns

2002-01-07 Thread Rodney Davis

Sorry for the newbie question but I can't find it in the docs.

How do I preserve carriage returns when inserting into
and extracting data from a mysql db?

I thought htmlspecialchars() would do the trick but it
doesn't.

thanks



RE: [PHP] carriage returns

2002-01-07 Thread Jon Haworth

Inserting data from a textarea or something?

If so, have a look at http://www.php.net/nl2br - probably what you're after.

Cheers
Jon


-Original Message-
From: Rodney Davis [mailto:[EMAIL PROTECTED]]
Sent: 07 January 2002 17:47
To: [EMAIL PROTECTED]
Subject: [PHP] carriage returns


Sorry for the newbie question but I can't find it in the docs.

How do I preserve carriage returns when inserting into
and extracting data from a mysql db?

I thought htmlspecialchars() would do the trick but it
doesn't.

thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]