MySQLdb insert HTML code error

Discussion in 'Python' started by Anatoli Hristov, Dec 11, 2012.

  1. 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
     
    Anatoli Hristov, Dec 11, 2012
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig Kenisston

    HTML code warnings in asp.net html code view

    Craig Kenisston, Oct 7, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,387
    Martin Dechev
    Oct 7, 2004
  2. Replies:
    3
    Views:
    12,844
    Beauregard T. Shagnasty
    Jan 10, 2006
  3. David Mitchell

    Problem With Insert with MySQLdb

    David Mitchell, Oct 30, 2005, in forum: Python
    Replies:
    3
    Views:
    469
    Magnus Lycka
    Nov 1, 2005
  4. =?ISO-8859-1?Q?Gerhard_H=E4ring?=

    Re: Problem With Insert with MySQLdb

    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Oct 31, 2005, in forum: Python
    Replies:
    2
    Views:
    353
    Dennis Lee Bieber
    Oct 31, 2005
  5. Sells, Fred

    MySQLdb insert fails on one table

    Sells, Fred, Jun 1, 2007, in forum: Python
    Replies:
    0
    Views:
    362
    Sells, Fred
    Jun 1, 2007
  6. Replies:
    1
    Views:
    2,152
    Albert Hopkins
    Dec 6, 2008
  7. mcnewsxp

    insert html into html

    mcnewsxp, Mar 30, 2010, in forum: HTML
    Replies:
    24
    Views:
    5,022
    cipherd
    Jan 7, 2012
  8. Sergio del Amo
    Replies:
    4
    Views:
    484
Loading...