Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; '%s"': 0.07; 'escape': 0.07; 'params': 0.07; 'subject:code': 0.07; 'cursor': 0.09; 'name):': 0.09; 'def': 0.10; 'subject:error': 0.11; 'description)': 0.16; 'inserting': 0.16; 'spec)': 0.16; 'spec,': 0.16; 'code.': 0.20; 'all,': 0.21; 'values': 0.26; 'message-id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; 'facing': 0.29; "i'm": 0.29; 'error': 0.30; 'code': 0.31; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'skip:m 40': 0.36; 'received:209': 0.37; 'description': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'face': 0.61; 'here': 0.65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=427D2HztF9VAJIaQwwG6DlpUkMvvMnxFnmjOXp2Yixs=; b=hUvNnDCo8yKgl6Qq34UDJVMV6m9s7V6lliGFGQIm6rNlM4o2TQ31rxZoxswH+YVt0C +7NtEVFsqMjA1DjI3bA0RpMRSr5GPI7ey1hZT4yKxEr/f9W7f3g3o7As1UMpO9+z59m2 ZC/NmXgdregphDPBqkoxyC44kSN/cQUPiKSZvJd16Sv1gM5mFaqwdKj0n5bgTNB9JwOU EDx4X7QRdWXbkx7z6YETLP7GsanhxavY7qzs8lIdKmJqKYMBVOGpDTtPSKnELz4q4+ED V/snO/M4p6+0dywPnF9hYEiNBce6kTnhiJK3v96Ds4l0+nIL/V03QRnX6RIupxP32Gah QTlg== MIME-Version: 1.0 Date: Tue, 11 Dec 2012 01:04:44 +0100 Subject: MySQLdb insert HTML code error From: Anatoli Hristov To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355184287 news.xs4all.nl 6843 [2001:888:2000:d::a6]:45445 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34583 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