|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Carriage ReturnsHello 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 |
|
|
Re: Carriage ReturnsAre you using nl2br to convert before recording or after?
"Dan Shirah" <mrsquash2@...> escreveu na mensagem news:a16da1ff0911060824k779f7457wa1111fd6e8f4e419@...... > 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Carriage ReturnsMy 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. 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Carriage Returns>
> 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.') |
|
|
Re: Carriage ReturnsDan 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 > 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: Carriage ReturnsOn Sun, Nov 8, 2009 at 11:40 AM, John List <johnlist@...> 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 > > \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: Carriage ReturnsDan 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 |
| Free embeddable forum powered by Nabble | Forum Help |