Hi;<br>I have this code:<br><br>#!/usr/bin/python<br><br>import cgitb; cgitb.enable()<br>import cgi<br>import sys,os<br>sys.path.append(os.getcwd())<br>import MySQLdb<br>from login import login<br><br>def create_edit_passengers4():<br>
print "Content-Type: text/html"<br> print<br> print '''<br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd</a>"><br>
<head xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"><br></head><br><body><br>'''<br> user, passwd, db, host = login()<br> database = MySQLdb.connect(host, user, passwd, db)<br>
cursor = database.cursor()<br> form = cgi.FieldStorage()<br> cursor.execute('create table if not exists Passengers (id int(11) auto_increment primary key, flights_id int(11) not null, customer_id int(11) not null, foreign key (id) references Flights (flights_id), foreign key (id) references Customers (customer_id), name varchar(40), weight int) engine=InnoDB;')<br>
new_passengers = int(form.getfirst('new_passengers'))<br> i = 0<br> while i < new_passengers:<br> cursor.execute('insert into Passengers values (Null, %s, %s, "%s", %s);' % (form.getfirst('%d:flight' % i), form.getfirst('%d:customer' % i), form.getfirst('%d:name' % i, ''), form.getfirst('%d:weight' % i)))<br>
i += 1<br> print "All passenger information has successfully been added."<br> cursor.close()<br> print "</body>\n</html>"<br><br>create_edit_passengers4()<br><br>Now, it throws no errors; however, it doesn't insert. If I print out the insert statement to screen and then manually insert it in MySQL it inserts. Huh??<br>
TIA,<br>beno<br>