Path: csiph.com!usenet.pasdenom.info!aioe.org!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; '%s"': 0.07; 'escape': 0.07; 'happen,': 0.07; 'params': 0.07; 'subject:code': 0.07; 'python': 0.09; 'cursor': 0.09; 'indication': 0.09; 'name):': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.10; 'subject:error': 0.11; 'definition.': 0.16; 'description)': 0.16; 'inserting': 0.16; 'perfect.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sadly': 0.16; 'spec)': 0.16; 'spec,': 0.16; 'wrote:': 0.17; 'code,': 0.18; 'code.': 0.20; 'all,': 0.21; 'os,': 0.22; "i'd": 0.22; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'header:X -Complaints-To:1': 0.28; 'skip:( 20': 0.28; 'ball': 0.29; 'facing': 0.29; "i'm": 0.29; 'usually': 0.30; 'version,': 0.30; 'error': 0.30; 'expect': 0.31; 'code': 0.31; 'from:addr:yahoo.co.uk': 0.32; 'could': 0.32; 'to:addr:python- list': 0.33; 'thanks': 0.34; 'received:org': 0.36; 'but': 0.36; 'skip:m 40': 0.36; 'enough': 0.36; 'subject:: ': 0.38; 'mark': 0.38; 'description': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'your': 0.60; "you've": 0.61; 'face': 0.61; 'kind': 0.61; 'assistance': 0.63; 'here': 0.65; 'repairs': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: MySQLdb insert HTML code error Date: Tue, 11 Dec 2012 00:22:09 +0000 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-18-13-73.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: X-Antivirus: avast! (VPS 121210-0, 10/12/2012), Outbound message X-Antivirus-Status: Clean 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355185240 news.xs4all.nl 6903 [2001:888:2000:d::a6]:54808 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34586 On 11/12/2012 00:04, Anatoli Hristov wrote: > 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 > As much use as a chocolate teapot, all you've given is a function/method definition. No indication of your OS, Python version, calling code, what you expect to happen, what actually happened, apart from that your request for assistance is perfect. Usually I'd be able to help but sadly my crystal ball is in for repairs at the moment. Would you please be kind enough to elucidate. -- Cheers. Mark Lawrence.