Change characters to html tags

Z

zek2005

Hi!!!

I have the following string in a MySQL Database

<p><strong>test</strong></p>

When I sent that information to a page I get the following string

<p><strong>test</strong></p>

What I actually need to show is the word "test" formated with the
above html tags

can you help me to resolve it?

Thanks!

Ezequiel
 
C

C A Upsdell

zek2005 said:
Hi!!!

I have the following string in a MySQL Database

&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;

When I sent that information to a page I get the following string

<p><strong>test</strong></p>

What I actually need to show is the word "test" formated with the
above html tags

can you help me to resolve it?

Replace each & by &amp;
 
R

Raymond SCHMIT

Hi!!!

I have the following string in a MySQL Database

&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;

When I sent that information to a page I get the following string

<p><strong>test</strong></p>

What I actually need to show is the word "test" formated with the
above html tags

can you help me to resolve it?

Thanks!

Ezequiel


Using:
$n = "<br />";
$txt3="&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;";
echo $txt3 . $n ;

give me also:
<p><strong>test</strong></p>

I will be also interested to know the solution ...
 
C

Chris F.A. Johnson

Hi!!!

I have the following string in a MySQL Database

&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;

When I sent that information to a page I get the following string

<p><strong>test</strong></p>

What I actually need to show is the word "test" formated with the
above html tags

can you help me to resolve it?

Either store the correct characters in the database or run the
output through a script that changes the entities to the
characters themselves, e.g.:

sed -e 's/&lt;/</g' -e 's/&gt;/>/g'
 
J

Jonathan N. Little

zek2005 said:
Hi!!!

I have the following string in a MySQL Database

&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;

When I sent that information to a page I get the following string

<p><strong>test</strong></p>

What I actually need to show is the word "test" formated with the
above html tags

can you help me to resolve it?

Thanks!

Well if you are using PHP

$mysql_string = '&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;';
$from = array("&lt;", "&gt;");
$to = array("<", ">");
$fixed_string = str_replace($from, $to, $mysql_string);
echo $fixed_string;
 
N

Nik Coughlin

Jonathan N. Little said:
Well if you are using PHP

$mysql_string = '&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;';
$from = array("&lt;", "&gt;");
$to = array("<", ">");
$fixed_string = str_replace($from, $to, $mysql_string);
echo $fixed_string;

If you're using PHP5 there is a built in function

$mysql_string = '&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;';
$fixed_string = htmlspecialchars_decode( $mysql_string );
echo $fixed_string;
 
N

Nico Schuyt

Jonathan said:
$mysql_string =
'&lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;';
$from = array("&lt;", "&gt;");
$to = array("<", ">");
$fixed_string = str_replace($from, $to, $mysql_string);
echo $fixed_string;

str_replace with an array?? Thanks for that information!
 
J

Jonathan N. Little

Nico said:
str_replace with an array?? Thanks for that information!

Yep. One of my complaints about PHP plethora of functions (I prefer
Perl's core 'terseness'), is it hard to keep track of them all.

http://us3.php.net/manual/en/function.str-replace.php
PHP: str_replace - Manual

More than once I have found *after* creating, debugging, and then
deploying a user function only to find PHP has a damn built in function.

Downloading the above manual is a must! And as Nik has posted PHP5 added
a slew more functions...
 
H

Harlan Messinger

Jonathan said:
Yep. One of my complaints about PHP plethora of functions (I prefer
Perl's core 'terseness'), is it hard to keep track of them all.

Isn't there an object-oriented version of PHP by now, with all these
utility functions organized as static methods of static classes like the
Math class in Java and C#, so that they can more easily be found and
used (even using something like MS Visual Studio's IntelliSense)?
 
R

Raymond SCHMIT

Yes Boss ! :)

Differences Between HTML and XHTML
In HTML the <br> tag has no end tag.

In XHTML the <br> tag must be properly closed, like this: <br />.



yes, i know the name of the group is alt.html ...and there is no
alt.xhtml group :)
 
L

Lars Eighner

the lovely and said:
yes, i know the name of the group is alt.html ...and there is no
alt.xhtml group :)

you should have been looking in alt.dogsbreakfast.bastardized.markup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top