Re: Carriage Returns

From: Date: Sun, 08 Nov 2009 17:43:00 +0000
Subject: Re: Carriage Returns
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-299703@lists.php.net to get a copy of this message
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,

« previous php.general (#299703) next »