Re: Can't Add Variable

2010-01-04 Thread MRAB

alex23 wrote:

On Jan 5, 3:40 am, Joe Riopel  wrote:

On Mon, Jan 4, 2010 at 12:28 PM, Victor Subervi  wrote:

Hi;
I have this code snippet:
sql '''create table if not exists %sCustomerData (

I think you may have forgotten the "=" after sql.


Jesus wept. How long is this list going to continue to finish Victor's
project for him?

These questions _clearly_ belong on python-tutor.


Who is this "Jesus" person? You should remember that this is a
predominantly Guido-worshipping list! :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can't Add Variable

2010-01-04 Thread alex23
On Jan 5, 3:40 am, Joe Riopel  wrote:
> On Mon, Jan 4, 2010 at 12:28 PM, Victor Subervi  
> wrote:
> > Hi;
> > I have this code snippet:
>
> >     sql '''create table if not exists %sCustomerData (
>
> I think you may have forgotten the "=" after sql.

Jesus wept. How long is this list going to continue to finish Victor's
project for him?

These questions _clearly_ belong on python-tutor.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't Add Variable

2010-01-04 Thread Victor Subervi
On Mon, Jan 4, 2010 at 1:42 PM, Chris Rebert  wrote:

> On Mon, Jan 4, 2010 at 9:28 AM, Victor Subervi 
> wrote:
> > Hi;
> > I have this code snippet:
> >
> > sql '''create table if not exists %sCustomerData (
>
> You're missing an equal sign there to start with (i.e. sql = ''').
>

LOL. I think it's time to put a gun to my head ;/ Thanks.
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't Add Variable

2010-01-04 Thread MRAB

Victor Subervi wrote:

Hi;
I have this code snippet:

sql '''create table if not exists %sCustomerData (
  ID tinyint(8) unsigned primary key auto_increment,
  Email varchar(120) not null,
  PhoneNumber varchar(20) not null,
  BillingName varchar(80) not null,
  BillingAddress1 varchar(100) not null,
  BillingAddress2 varchar(100) null,
  BillingCity varchar(50) not null,
  BillingState varchar(2) not null,
  BillingPostalCode varchar(8) not null,
  ShippingName varchar(80) not null,
  ShippingAddress1 varchar(100) not null,
  ShippingAddress2 varchar(100) null,
  ShippingCity varchar(50) not null,
  ShippingState varchar(2) not null,
  ShippingPostalCode varchar(8) not null,
  TypeOfCard set("VISA", "MasterCard", "AmEx", "Discover", "PayPal") 
null,

  CreditCardNumber tinyint(8) unsigned null,
  CreditCardExpMonth tinyint(2) unsigned null,
  CreditCardExpYear tinyint(4) unsigned null
  );''' % store

It throws this error:

[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61]   File 
"/var/www/html/angrynates.com/cart/cart2.py 
", line 62, referer: 
http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] );''' % 
store, referer: http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] ^, 
referer: http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] SyntaxError: 
invalid syntax, referer: http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] Premature end of 
script headers: cart2.py, referer: http://angrynates.com/cart/cart.py


Variable "store" is defined. How is my syntax invalid? Total code follows.


If it was complaining that "store" wasn't defined, the exception would
have been NameError.

It's a SyntaxError because of the missing "=".
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can't Add Variable

2010-01-04 Thread Chris Rebert
On Mon, Jan 4, 2010 at 9:28 AM, Victor Subervi  wrote:
> Hi;
> I have this code snippet:
>
>     sql '''create table if not exists %sCustomerData (

You're missing an equal sign there to start with (i.e. sql = ''').

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't Add Variable

2010-01-04 Thread Stephen Hansen
On Mon, Jan 4, 2010 at 9:28 AM, Victor Subervi wrote:

> Hi;
> I have this code snippet:
>
> sql '''create table if not exists %sCustomerData (
>

You left out the actual assignment operator.

--S
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't Add Variable

2010-01-04 Thread Joe Riopel
On Mon, Jan 4, 2010 at 12:28 PM, Victor Subervi  wrote:
> Hi;
> I have this code snippet:
>
>     sql '''create table if not exists %sCustomerData (

I think you may have forgotten the "=" after sql.
-- 
http://mail.python.org/mailman/listinfo/python-list


Can't Add Variable

2010-01-04 Thread Victor Subervi
Hi;
I have this code snippet:

sql '''create table if not exists %sCustomerData (
  ID tinyint(8) unsigned primary key auto_increment,
  Email varchar(120) not null,
  PhoneNumber varchar(20) not null,
  BillingName varchar(80) not null,
  BillingAddress1 varchar(100) not null,
  BillingAddress2 varchar(100) null,
  BillingCity varchar(50) not null,
  BillingState varchar(2) not null,
  BillingPostalCode varchar(8) not null,
  ShippingName varchar(80) not null,
  ShippingAddress1 varchar(100) not null,
  ShippingAddress2 varchar(100) null,
  ShippingCity varchar(50) not null,
  ShippingState varchar(2) not null,
  ShippingPostalCode varchar(8) not null,
  TypeOfCard set("VISA", "MasterCard", "AmEx", "Discover", "PayPal")
null,
  CreditCardNumber tinyint(8) unsigned null,
  CreditCardExpMonth tinyint(2) unsigned null,
  CreditCardExpYear tinyint(4) unsigned null
  );''' % store

It throws this error:

[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61]   File
"/var/www/html/angrynates.com/cart/cart2.py", line 62, referer:
http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] );''' % store,
referer: http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] ^, referer:
http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] SyntaxError: invalid
syntax, referer: http://angrynates.com/cart/cart.py
[Mon Jan 04 09:23:54 2010] [error] [client 66.82.9.61] Premature end of
script headers: cart2.py, referer: http://angrynates.com/cart/cart.py

Variable "store" is defined. How is my syntax invalid? Total code follows.
TIA,
beno

#! /usr/bin/python

import string
import cgitb; cgitb.enable()
import MySQLdb
import cgi
import sys,os
sys.path.append(os.getcwd())
from login import login
import datetime, Cookie, random
from particulars import title, myCookie, ourOptions, whereToShip,
paymentOptionsPickup, paymentOptionsFax, paymentGateways, VISA, masterCard,
amEx, discover, payPal
from templateFrame import top, bottom
import time
import fpformat
from sets import Set

ourURL = string.split(__file__, 'html/')
ourURL = string.split(ourFile[1], '/')[0]

def commitSale():
  user, passwd, db, host = login()
  database = MySQLdb.connect(host, user, passwd, db)
  cursor= database.cursor()
  ourEmail = email()
  form = cgi.FieldStorage()
  which = form.getfirst('which')
  store = form.getfirst('store')
  patientID = form.getfirst('patientID')
  customerLoginEmail = form.getfirst('customerEmail') # This is for
customers who lost their login info
  customerLoginFirstName = form.getfirst('customerLoginFirstName')
  customerLoginLastName = form.getfirst('customerLoginLastName')
  customerLoginData = [patientID, customerLoginEmail,
customerLoginFirstName, customerLoginLastName]
  if (store == 'prescriptions') and ((customerLoginEmail is not None) or
(customerLoginFirstName is not None)):
myMail(which, store, '', ourURL, '', '', customerLoginData)
  elif which == 'order':
form = cgi.FieldStorage()
tmpTable = form.getfirst('tmpTable')
howPay = form.getfirst('howPay')
ccNumber = form.getfirst('creditCardNumber')
ccFirstHalf = ccNumber[0:8]
ccSecondHalf = ccNumber[8:]
sql '''create table if not exists %sCustomerData (
  ID tinyint(8) unsigned primary key auto_increment,
  Email varchar(120) not null,
  PhoneNumber varchar(20) not null,
  BillingName varchar(80) not null,
  BillingAddress1 varchar(100) not null,
  BillingAddress2 varchar(100) null,
  BillingCity varchar(50) not null,
  BillingState varchar(2) not null,
  BillingPostalCode varchar(8) not null,
  ShippingName varchar(80) not null,
  ShippingAddress1 varchar(100) not null,
  ShippingAddress2 varchar(100) null,
  ShippingCity varchar(50) not null,
  ShippingState varchar(2) not null,
  ShippingPostalCode varchar(8) not null,
  TypeOfCard set("VISA", "MasterCard", "AmEx", "Discover", "PayPal")
null,
  CreditCardNumber tinyint(8) unsigned null,
  CreditCardExpMonth tinyint(2) unsigned null,
  CreditCardExpYear tinyint(4) unsigned null
  );''' % store
print sql
#cursor.execute(sql)
sql = '''insert into %sCustomerData (Email, PhoneNumber, BillingName,
BillingAddress1, BillingAddress2,
BillingCity, BillingState, BillingPostalCode, ShippingName,
ShippingAddress1, ShippingAddress2, ShippingCity,
ShippingState, ShippingPostalCode, TypeOfCard, CreditCardNumber,
CreditCardExpMonth, CreditCardExpYear)
value ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s",
"%s", "%s", "%s", "%s", "%s", "%s", "%s");'
% (store, form.getfirst('customerEmail'),
form.getfirst('customerPhoneNumber'), form.getfirst('customerBillingName'),
form.getfirst('customerBillingAddr1'),
form.getfirst('customerBillingAddr2'), form.getfirst('customerBillingCity'),
form.getfirst('customerBil