homepage Welcome to WebmasterWorld Guest from 54.161.220.160
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
mysql php/html INSERT
dav_999

5+ Year Member



 
Msg#: 3858168 posted 1:39 pm on Feb 26, 2009 (gmt 0)

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

 

blang

5+ Year Member



 
Msg#: 3858168 posted 1:47 pm on Feb 26, 2009 (gmt 0)

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?

dav_999

5+ Year Member



 
Msg#: 3858168 posted 2:02 pm on Feb 26, 2009 (gmt 0)

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 ?

dav_999

5+ Year Member



 
Msg#: 3858168 posted 2:16 pm on Feb 26, 2009 (gmt 0)

but that's not worked... <<<
means
longtext and text working but saving half data not the full from <html to </html

coopster

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



 
Msg#: 3858168 posted 4:18 pm on Feb 26, 2009 (gmt 0)

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?

dav_999

5+ Year Member



 
Msg#: 3858168 posted 4:30 pm on Feb 26, 2009 (gmt 0)

using phpmyadmin

dav_999

5+ Year Member



 
Msg#: 3858168 posted 4:34 pm on Feb 26, 2009 (gmt 0)

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

coopster

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



 
Msg#: 3858168 posted 4:55 pm on Feb 26, 2009 (gmt 0)

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 ... ");

dav_999

5+ Year Member



 
Msg#: 3858168 posted 6:02 pm on Feb 26, 2009 (gmt 0)

`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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved