Greetings:
I am writing a python db script and am getting the infamous Premature end of script headers:
#!/usr/bin/env python
# import MySQL module
import MySQLdb
db = MySQLdb.connect (host = "localhost"
,user = "myusername"
,passwd = "mypassword"
,db = "mydatabase")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("SELECT * FROM category ORDER BY category ASC;")
# get the number of rows in the resultset
numrows = int(cursor.rowcount)
# get and display one row at a time in the select list
print "Content-Type: text/html\n\n"
print ... results from select statement.
Is there a problem with how I am trying to connect to the database here? Is the syntax off for trying to connect to the db. Is MySQLdb for python installed on tch?
A simple hello world script as follows works with no problems.
#!/usr/bin/env python
print "Content-Type: text/html\n\n"
print "Hello World"
Any python insights would be helpful. Thanks.