$business = safeHTML($_POST["business"]); What is

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
supaseeds
Forum Newbie
Posts: 13
Joined: Tue Jul 13, 2004 8:09 am

$business = safeHTML($_POST["business"]); What is

Post by supaseeds »

I think the problems in this line:
$business = safeHTML($_POST["business"]);

safeHTML??? Is this likely to be affecting the text submitted?



I've got a variable $f[business] which is retrieved from a MYSQL database. The field is set to 'TEXT' and contains text in HTML format so its got <b> <p> etc...
Unfortunetly it reads the text as is and just prints all the HTML commands on the page ignoring it as actual code - How do I get it to read the HTML code??

Thanks in advance...[/b]
Last edited by supaseeds on Mon Jul 26, 2004 8:07 am, edited 3 times in total.
supaseeds
Forum Newbie
Posts: 13
Joined: Tue Jul 13, 2004 8:09 am

Post by supaseeds »

OK, im one step closer with

Code: Select all

echo html_entity_decode($f&#1111;business]);
but it wont read <br> or <P> etc only <B>
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

[php_man]htmlspecialchars[/php_man] ?
supaseeds
Forum Newbie
Posts: 13
Joined: Tue Jul 13, 2004 8:09 am

Post by supaseeds »

Thanks for the help but with
PHPSPECIALCHARS I get:

TEST<B>TEST</B>

printed on screen. In the MYSQL database it stores the data in the same manor, but I've noticed its simply not storing <BR> in the database at all....


I think the problems in this line:
$business = safeHTML($_POST["business"]);

safeHTML??? Is this likely to be affecting the text submitted?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

how about:

Code: Select all

$business = nl2br(htmlentities($_POST['business'],ENT_QUOTES));
d_d
Forum Commoner
Posts: 33
Joined: Wed Jul 07, 2004 4:56 pm
Location: UK

Post by d_d »

supaseeds wrote: I think the problems in this line:
$business = safeHTML($_POST["business"]);

safeHTML??? Is this likely to be affecting the text submitted?
Proberly, otherwise why send the submitted text through the safeHTML function?

I think safeHTML is a user function, find it and see what it does. It is proberly stoping all html from working which is proberly what you want. Then all you will need to do is replace all line breaks with <br> with either with nl2br() or str_replace().
Post Reply