MySQLdb insert HTML code error

A

Anatoli Hristov

Hi all,

I'm facing an issue inserting an html code into the DB, it comes out
with a syntax error but I face it only when I have html code. Could
help me escape the error somehow ?

Here is my code

def InsertSpecsDB(product_id, spec, lang, name):
db = MySQLdb.connect("localhost","getit","opencart")
cursor = db.cursor()
sql = ("INSERT INTO product_description (product_id, language_id,
name, description) VALUES ('%s','%s','%s','%s')")
params = (product_id, lang, name, spec)
cursor.execute(sql, params)
id = cursor.lastrowid
print"Updated ID %s description %s" %(int(id), lang)
return id

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top