By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Displaying database contents on the web

P: n/a
FP
I have a comments field in my database that I want on the web.
I put some weird characters in for testing.
When I had <bin the comment field it turned all text after that bold.
I tried using htmlspecialchars() & htmlentities() but then I got
"”" instead of a quote.

The code I'm using to display the text in HTML is:
<TD>
<P><FONT SIZE="+1">
<? echo(htmlentities($ResultOne['Comment'][0])); ?>
</FONT></P>
</TD>

Do I need to change the HTML code or is there a PHP function that will
handle all weird characters in this situation? Please keep in mind I'm
fairly new to this, so if there's an obvious answer just point me in
the right direction.

P.S.
Someone had suggested using a regex function but I couldn't find that
in my manual, I assumed they were referring to the htmlspecialchars()
function.

Jul 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
For clarification, I take it that you want your quotes to remain as
quotes, and not become html entities. You were close, just use the
following

htmlentities( $str, ENT_NOQUOTES ); // leaves ' and " as they are
FP wrote:
I have a comments field in my database that I want on the web.
I put some weird characters in for testing.
When I had <bin the comment field it turned all text after that bold.
I tried using htmlspecialchars() & htmlentities() but then I got
"”" instead of a quote.

The code I'm using to display the text in HTML is:
<TD>
<P><FONT SIZE="+1">
<? echo(htmlentities($ResultOne['Comment'][0])); ?>
</FONT></P>
</TD>

Do I need to change the HTML code or is there a PHP function that will
handle all weird characters in this situation? Please keep in mind I'm
fairly new to this, so if there's an obvious answer just point me in
the right direction.

P.S.
Someone had suggested using a regex function but I couldn't find that
in my manual, I assumed they were referring to the htmlspecialchars()
function.
Jul 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.