Connecting Tech Pros Worldwide Help | Site Map

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

Mandragon03@gmail.com
Guest
 
Posts: n/a
#1: Aug 18 '08
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!
Jerry Stuckle
Guest
 
Posts: n/a
#2: Aug 18 '08

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


Mandragon03@gmail.com wrote:
Quote:
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.
jstucklex@attglobal.net
==================

Mandragon03@gmail.com
Guest
 
Posts: n/a
#3: Aug 18 '08

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


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

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


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