Re: Carriage Returns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux