Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:37:45+00:00 2026-05-14T02:37:45+00:00

## COMMENT OUT below just for reference cursor.execute ( CREATE TABLE yellowpages ( business_id

  • 0
## COMMENT OUT below just for reference
""
cursor.execute ("""
    CREATE TABLE yellowpages
    (
        business_id     BIGINT(20) NOT NULL AUTO_INCREMENT,
        categories_name VARCHAR(255),
        business_name   VARCHAR(500) NOT NULL,
        business_address1 VARCHAR(500),
        business_city VARCHAR(255),
        business_state VARCHAR(255),
        business_zipcode VARCHAR(255),
        phone_number1 VARCHAR(255),
        website1 VARCHAR(1000),
        website2 VARCHAR(1000),
        created_date datetime,
        modified_date datetime,
        PRIMARY KEY(business_id)
    )
""")
""
## TOP COMMENT OUT (just for reference)

## code
website1g = "http://www.triman.com"
business_nameg = "Triman Sales Inc"
business_address1g = "510 E Airline Way"
business_cityg = "Gardena"
business_stateg = "CA"
business_zipcodeg = "90248"
phone_number1g = "(310) 323-5410"
phone_number2g = ""
website2g = ""

cursor.execute ("""
    INSERT INTO yellowpages(categories_name, business_name, business_address1, business_city, business_state, business_zipcode, phone_number1, website1, website2)
    VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')
""", (''gas-stations'', business_nameg, business_address1g, business_cityg, business_stateg, business_zipcodeg, phone_number1g, website1g, website2g))


cursor.close()
conn.close()

I keep getting this error

  File "testdb.py", line 51
    """, (''gas-stations'', business_nameg, business_address1g, business_cityg, business_stateg, business_zipcodeg, phone_number1g, website1g, website2g))
              ^
SyntaxError: invalid syntax

any idea why?

Thanks for the help in advance


Update #2, I have removed the double single quote on the “categories_name”, but now even

import MySQLdb  

conn =  MySQLdb.connect(host="localhost",port=22008,user="cholestoff",passwd="whoami",db="mydatabase")  
cursor = conn.cursor()  

## Find mysql version  
cursor.execute ("SELECT VERSION()")  
row = cursor.fetchone()  
print "server version:", row[0]  

website1g = "http://www.triman.com"  
business_nameg = "Triman Sales Inc"  
business_address1g = "510 E Airline Way"  
business_cityg = "Gardena"  
business_stateg = "CA"  
business_zipcodeg = "90248"  
phone_number1g = "(310) 323-5410"  
phone_number2g = ""  

cursor.execute ("""
    INSERT INTO yellowpages(categories_name, business_name)
    VALUES ('%s','%s')
""", ('gas-stations', business_nameg))              

cursor.close()  
conn.close()  

still gotten this error

server version: 5.1.33-community  
Traceback (most recent call last):  
  File "testdb.py", line 23, in <module>  
    """, ('gas-stations', business_nameg))  
  File "C:\Python26\lib\site-packages\MySQLdb\cursors.py", line 173, in execute  
    self.errorhandler(self, exc, value)  
  File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line 36, in   defaulterrorhandler  
    raise errorclass, errorvalue  
_mysql_exceptions.ProgrammingError: (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 'gas-stations'',''Triman Sales Inc'')' at line 2")

Thanks again for the help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:37:45+00:00Added an answer on May 14, 2026 at 2:37 am

    I think your problem is here:

    ''gas-stations''
    

    This gives a syntax error. You probably want to use one set of quotes:

    'gas-stations'
    

    If you want to insert the value 'gas-stations' into the database including the quotes then you can either escape the quotes or surround the string with double-quotes instead of single quotes:

    "'gas-stations'"
    

    The reason why the “up arrow” is pointing at the wrong place is because your lines are so long that it is wrapping on your console. Make your lines shorter, or widen your console window to see where the error really is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No. CCSprite is not retaining the filename. But like you… May 16, 2026 at 5:48 pm
  • Editorial Team
    Editorial Team added an answer The latitude/longitude pair 0/0 is on the equator due south… May 16, 2026 at 5:48 pm
  • Editorial Team
    Editorial Team added an answer To find the "distance" between two strings, a simple method… May 16, 2026 at 5:48 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

How do I comment out a block of tags in XML? I.e. How can
Apparently there's a lot of variety in opinions out there, ranging from, " Never!
Hey this question is in reply to Joel Hooks 's comment on an older
I just switched two projects over to fogbugz and so far I like it
I'm trying to figure out why I would use a grid system. I have
I was reading over http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html But I'm really not grasping how to ignore certain
In the code below, the combo box named ConnectionType shows the selected item, but
I'm fetching some objects out of a data store but the results aren't what
A common way I handle things in Drupal is to create a CCK type,
I have programmed in C, Pascal, GWBasic, TCL, Perl, Lisp, but Visual Basic is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.