Problem to retrieve information from a mysql database

This is a discussion on Problem to retrieve information from a mysql database within the PHP Language forums, part of the PHP Programming Forums category; Hi! I have a value loaded in a database as following: <p><strong&...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-25-2008
zek2005
 
Posts: n/a
Default Problem to retrieve information from a mysql database

Hi!

I have a value loaded in a database as following:

<p><strong>test</strong></p>
<p><strong>test 2</
strong><em><strong>questions<img alt=""
src="http://www.mysite.com/fckeditor/edit...es/smiley/msn/
regular_smile.gif" /></strong></em></p>

when I retrieve the information in a web page using $row[pregunta]
(the above value is stored in the previuos variable) the value shown
is:

<p><strong>test</strong></p> <p><strong>test 2</
strong><em><strong>questions<img alt="" src="http://www.mysite.com/
fckeditor/editor/images/smiley/msn/regular_smile.gif" /></strong></
em></p>

when actually what I need to show is the formates text using the HTML
tags.

Anyone can help me to solved why the string is shown with the HTML
tags and not formated'

Thanks!

Zek
Reply With Quote
  #2 (permalink)  
Old 06-25-2008
Jerry Stuckle
 
Posts: n/a
Default Re: Problem to retrieve information from a mysql database

zek2005 wrote:
> Hi!
>
> I have a value loaded in a database as following:
>
> &lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;
> &lt;p&gt;&lt;strong&gt;test 2&lt;/
> strong&gt;&lt;em&gt;&lt;strong&gt;questions&lt;img alt=&quot;&quot;
> src=&quot;http://www.mysite.com/fckeditor/edit...es/smiley/msn/
> regular_smile.gif&quot; /&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
>
> when I retrieve the information in a web page using $row[pregunta]
> (the above value is stored in the previuos variable) the value shown
> is:
>
> <p><strong>test</strong></p> <p><strong>test 2</
> strong><em><strong>questions<img alt="" src="http://www.mysite.com/
> fckeditor/editor/images/smiley/msn/regular_smile.gif" /></strong></
> em></p>
>
> when actually what I need to show is the formates text using the HTML
> tags.
>
> Anyone can help me to solved why the string is shown with the HTML
> tags and not formated'
>
> Thanks!
>
> Zek
>


This has nothing to do with PHP. It's how HTML works. &lt;p&gt; will
always display <p>. If you want a paragraph tag, you use a paragraph
tag: <p>. And so on. You can get more help on this in alt.html.

But why are you even storing html tags in your database. You should be
storing the data in a display-independent format and format the items
when you retrieve them. For more help on this end, see your favorite
database newsgroup.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #3 (permalink)  
Old 06-25-2008
FutureShock
 
Posts: n/a
Default Re: Problem to retrieve information from a mysql database

zek2005 wrote:
> Hi!
>
> I have a value loaded in a database as following:
>
> &lt;p&gt;&lt;strong&gt;test&lt;/strong&gt;&lt;/p&gt;
> &lt;p&gt;&lt;strong&gt;test 2&lt;/
> strong&gt;&lt;em&gt;&lt;strong&gt;questions&lt;img alt=&quot;&quot;
> src=&quot;http://www.mysite.com/fckeditor/edit...es/smiley/msn/
> regular_smile.gif&quot; /&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
>
> when I retrieve the information in a web page using $row[pregunta]
> (the above value is stored in the previuos variable) the value shown
> is:
>
> <p><strong>test</strong></p> <p><strong>test 2</
> strong><em><strong>questions<img alt="" src="http://www.mysite.com/
> fckeditor/editor/images/smiley/msn/regular_smile.gif" /></strong></
> em></p>
>
> when actually what I need to show is the formates text using the HTML
> tags.
>
> Anyone can help me to solved why the string is shown with the HTML
> tags and not formated'
>
> Thanks!
>
> Zek

You can try using htmlspecialchars(). This is usually used to prevent
html entities from displaying as html such as < >. But it may preserve
the the original markup when displayed in a browser.
If you can give a reason why you are using this particular data, there
may be a better way to accomplish what you want to do.

Scotty
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:56 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0