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

PhP and mysql won't do this insert. Help please...

P: n/a
I am trying to insert html into a mysql data base with the following
query:

$realHTMLText = addslashes($_POST["NewsHTML"]);
INSERT INTO html_Table (Content) VALUES (' $realHTMLText ' )";

The post is taking from data from a textarea.

If I type this into the text area:

hello <div>

and submit the entry in mysql is only "hello"

however if I type this:

hello < div>

it works just fine. Can anyone shed some light on what is going on
here?

Thanks so much!
Aug 18 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ma*********@gmail.com wrote:
I am trying to insert html into a mysql data base with the following
query:

$realHTMLText = addslashes($_POST["NewsHTML"]);
INSERT INTO html_Table (Content) VALUES (' $realHTMLText ' )";

The post is taking from data from a textarea.

If I type this into the text area:

hello <div>

and submit the entry in mysql is only "hello"

however if I type this:

hello < div>

it works just fine. Can anyone shed some light on what is going on
here?

Thanks so much!
First of all, you should not be using addslashes(). See
mysql_real_escape_string() instead.

Secondly, are you looking at the output in your browser window, or the
source to that output (i.e. View Source in Firefox)?

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

Aug 18 '08 #2

P: n/a
On Aug 17, 8:35*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Mandrago...@gmail.com wrote:
I am trying to insert html into a mysql data base with the following
query:
$realHTMLText = addslashes($_POST["NewsHTML"]);
INSERT INTO html_Table *(Content) VALUES (' $realHTMLText ' )";
The post is taking from data from a textarea.
If I type this into the text area:
hello <div>
and submit the entry in mysql is only "hello"
however if I type this:
hello < div>
it works just fine. Can anyone shed some light on what is going on
here?
Thanks so much!

First of all, you should not be using addslashes(). *See
mysql_real_escape_string() instead.

Secondly, are you looking at the output in your browser window, or the
source to that output (i.e. View Source in Firefox)?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I was echoing the query string to the browser window (firefox). I
tried mysql_real_escape_string() and had problems I can try it again.
Aug 18 '08 #3

P: n/a
On Aug 17, 9:51*pm, Mandrago...@gmail.com wrote:
On Aug 17, 8:35*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Mandrago...@gmail.com wrote:
I am trying to insert html into a mysql data base with the following
query:
$realHTMLText = addslashes($_POST["NewsHTML"]);
INSERT INTO html_Table *(Content) VALUES (' $realHTMLText ' )";
The post is taking from data from a textarea.
If I type this into the text area:
hello <div>
and submit the entry in mysql is only "hello"
however if I type this:
hello < div>
it works just fine. Can anyone shed some light on what is going on
here?
Thanks so much!
First of all, you should not be using addslashes(). *See
mysql_real_escape_string() instead.
Secondly, are you looking at the output in your browser window, or the
source to that output (i.e. View Source in Firefox)?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

I was echoing the query string to the browser window (firefox). I
tried mysql_real_escape_string() and had problems I can try it again.
Ok now I feel stupid. It is fine. Of course the browser would render
it as a <divtag and I would only be able to view it with "view
source". Thanks for helping me clear this up.
Aug 18 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.