How to insert javascript into mysql database?

I'm facing this issue when i try to insert an javascript link

Database error 1064: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near 'text/javascript'   
src='http://www.domain.com/js/embed.js'></script>'' at line 3

Besides that javascript link, it accepted the text and youtube embedded code too . How to rectify this issue ?

and here is the table

 CREATE TABLE IF NOT EXISTS `livedata` (
`livedata_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`livedata_cat_id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`code` text NOT NULL,
 PRIMARY KEY (`livedata_id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=78 ;

my Htm code

 <textarea class="text-input textarea" id="textarea" name="code" cols="100" rows="8"></textarea>

Answers:

Answer

Not commenting on what you are actually doing, but your problem is in the apostrophes. Do escape them using mysql_real_escape_string.

Answer

Consider using base64_encode an base64_decode

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.