I had a similar issue and this is the solution i came up with. I have often wondered if this is the right way of doing it or not, but I'm by far not a PHP guru, just learning.

before inserting into the database I encode the data using the htmlspecialchars() function.

$encReq = htmlspecialchars($req, ENT_QUOTES);

when I'm displaying it back to the user i had to use the following function to convert it back into HTML.

function unhtmlspecialchars( $string )
{
    $string = str_replace ( '&', '&', $string );
    $string = str_replace ( ''', '\'', $string );
    $string = str_replace ( '"', '"', $string );
    $string = str_replace ( '&lt;', '<', $string );
    $string = str_replace ( '&gt;', '>', $string );
   
    return $string;
}

This is something i came across after doing some reading though the PHP manual and some of the user comments on the subject.

If anything knows of a more effective and efficient method, I'd love to know about it.

Thanks,
Yusuf.

On 10/19/06, David Krings < [EMAIL PROTECTED]> wrote:
Hi,

    you can't display tab in HTML and the textarea box takes just plain
ASCII. So any fancy spacing, indenting or such will either be stripped
or shown as single spaces. And HTML also cannot display an arry of
simple white space. You would need to convert that to non-breaking
spaces. But isn't there a function that translates all kinds of things
to the equivalent HTML code?

Ben Sgro (sk) wrote:
> Felix,
>
> Sure, that is helpful, but what about tabs, lists and all the other
> elements that could exist in an email message.
> I'm looking for a canned function or class that will do the work.
>
> Thanks.
>
> - Ben
>
> ....some code.....
> $details   = str_replace("\n\r", "<br>", $cellSet[0]['info']);

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to