Hi,
I am reading from a database and putting html code as well into a variable. The output includes the html code. I dont want it to.
This is what I put into my page:
<?php echo $AboutYourBusiness ?>
The output of this is:
<p>Test, Test, Test.</p> <p>Another Test, Another Test, Another Test.</p>
I don't want the output to include the <p> brackets. I store them in the database text field so that I can have the output correctly formatted over several paragraphs.
This is what I want the output to be:
Test, Test, Test.
Another Test, Another Test, Another Test.
When I look at the source of the page the brackets have been output as <p>
How can I not have the output as <p> and have it as <p>
Thanking you in advance for help.
Denise
I need output from database variable without the html code
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: I need output from database variable without the html code
Code: Select all
echo htmlspecialchars_decode($AboutYourBusiness);Code: Select all
echo html_entity_decode($AboutYourBusiness);Re: I need output from database variable without the html code
Or simply don't encode your HTML as you put it in the database. Why would you be doing that?
Re: I need output from database variable without the html code
Thanks superdezign, it works!
Pytrin, I can see your point. I didn't know that I was encoding it. It goes into an sql long text field. What am I doing wrong that encodes it?
Denise
Pytrin, I can see your point. I didn't know that I was encoding it. It goes into an sql long text field. What am I doing wrong that encodes it?
Denise
Re: I need output from database variable without the html code
nice post there. 
Re: I need output from database variable without the html code
Somewhere in the process an HTML encoding function is ran. It is probably htmlentities() or htmlspecialchars() - you don't need to encode data to enter it in the database, only escape it (using something mysql_real_escape_string()). Find where that encoding occurs, and remove it.Pytrin, I can see your point. I didn't know that I was encoding it. It goes into an sql long text field. What am I doing wrong that encodes it?
Re: I need output from database variable without the html code
Thanks everyone, got it working. 