I have been trying similar arrangements, but to no avail. I think it
has something to do with the actual string I am checking - it's an SQL
statement. I am trying to create a log of SQL statements in a textfile,
and the newline/return characters that people put in the TEXTAREA is
screwing it up. But I can't for the life of me figure out why test code
such as this does not strip out the \n's...
-----
$sql = "UPDATE contact set firstname = 'rory', lastname = 'jones',
interest = 'rory', optin = 'yes', comments = 'hello\n\n,rory' WHERE id =
5055";
$sql2=$sql;
$sql2=str_replace("","\n",$sql2);
$sql2=str_replace("","\r",$sql2);
-----
it is still outputting the following to my log:
-----
UPDATE contact set firstname = 'rory', lastname = 'jones' interest =
'rory' optin = 'yes' comments = 'hello
,rory' WHERE id = 5055;
-----
Any help is appreciated!
Thanks
On Sat, 25 Aug 2001 11:17:43 -0700, Rory O'Connor <[EMAIL PROTECTED]>
wrote:
>I had the same problem, I was writing the textarea to a text file,and
>reading it using fgets, therefor, any unspecified newlines would really
mess
>my script up. This probably isn't the best solution, but it'swhat I
used,and
>works fine.
>
>$data=$textarea;
>$data=str_replace("","\n",$data);
>$data=str_replace("","\r",$data);
>
>That's all there was to it, it replaced all newlines and returns with
>blanks. You can change it to replace with breaks if you are outputting
to an
>HTML file, hope I was able to help,
>-Andy
>----- Original Message -----
>From: Rory O'Connor <[EMAIL PROTECTED]>
>Newsgroups: php.general
>To: PHP list <[EMAIL PROTECTED]>
>Sent: Saturday, August 25, 2001 9:27 AM
>Subject: Stripping line break characters
>
>
>> I need to strip line break characters (or whatever the character is
that
>> results from users hitting their "enter" key inside a TEXTAREA form
>> input) from a string. These characters will appear anywhere in the
>> string, not just at the end. In perl, the regex would look
something
>> like this...
>>
>> $a="a\nb\nc\nd\n\n\n";
>> $b=$/;
>> $a =~ s/$b//g; # produces "abcd"
>>
>> but i'm a newbie and i don't know how I can translate this to PHP
syntax
>> to do the same thing. Any help is appreciated!
>>
>> Thanks!
>>
>>
>>
>> providing the finest in midget technology
>
>
>
providing the finest in midget technology
--
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]