Welcome to WebmasterWorld Guest from 54.144.48.252

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

mysql php/html INSERT

     
1:39 pm on Feb 26, 2009 (gmt 0)

5+ Year Member



hi,
i want to INSERT html CODE data to mysql without using any type of html form etc.. the code i tried

mysql_query("INSERT INTO `some` VALUES ('" . mysql_real_escape_string($html) . "')");

but thats not worked...

any idea plz

$html is like any page html code ...

the mysql type for html is i tried text and longtext both are not working using mysql_real_escape_string its INSERT the half data not the full

1:47 pm on Feb 26, 2009 (gmt 0)

5+ Year Member



but that's not worked...

Can you define "not worked"? What does it do / not do? Are you using htmlentities() or a related function on the markup prior to insertion or are you just escaping it with m_r_e_s()?

Ah, it seems that I either missed something or you edited your post. How long is the string you're trying to insert? Did you check the length of the TEXT data types [dev.mysql.com] to make sure it would fit?

2:02 pm on Feb 26, 2009 (gmt 0)

5+ Year Member



i already checked the length its
LONGTEXTA string with a maximum length of 4294967295 characters.
and
TEXTA string with a maximum length of 65535 characters.

in my case i tried both of them but with both i just see its INSERT the half data
and yes i am only doing mysql_real_escape_string
can htmlentities help how do i use it ?

2:16 pm on Feb 26, 2009 (gmt 0)

5+ Year Member



but that's not worked... <<<
means
longtext and text working but saving half data not the full from <html to </html
4:18 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld, dav_999.

How do you know it is only saving half the string? How are you viewing the data in the table row?

4:30 pm on Feb 26, 2009 (gmt 0)

5+ Year Member



using phpmyadmin
4:34 pm on Feb 26, 2009 (gmt 0)

5+ Year Member



just example
if html is
what what what.... the css javascript some text etc.....
(in example i am not using the real html)

so its insert what what what.... the cs
----------

i just think its because of spacial characters so is there any way to save spacial cha's.. in mysql

4:55 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You may need to provide your table definition, or at least the column definition. Also, try dumping the variable to the browser right before you attempt to insert it to be certain that you are indeed capturing the entire string. For example:
print '>>>' . htmlentities($html) . '<<<'; 
exit;

mysql_query("INSERT ... ");
6:02 pm on Feb 26, 2009 (gmt 0)

5+ Year Member



`html` longtext character set utf8 NOT NULL,

the issue is the special characters in html, is there any wany to convert special characters to UTf8

 

Featured Threads

Hot Threads This Week

Hot Threads This Month