View Single Post
Old Feb 16th, 2008, 12:19 AM   #16
Swan
Newbie
 
Join Date: Jan 2008
Posts: 27
Rep Power: 0 Swan is on a distinguished road
Re: Running python scripts on localhost

Quote:
Originally Posted by Sane View Post
Firstly: Refer to my very first reply in this thread. Does your code begin with, and follow, that template?

Secondly: Does the code at least compile in your local Python interpreter?

Thirdly: Please wrap your code in [code][/code] tags next time.

Fourthly: Your code does not even have a single print statement. How do you expect it to make visible output? Do you even know how to program in Python?

Ok so according to you ,i should test this :

#!c:/python24/python

import cgitb
import cgi
cgitb.enable()

print "Content-type: text/html\r"
print "\r"

class Eb_db:
def __init__(self):
try:
connection = MySQLdb.connect(host="localhost",
user="swan", passwd="swan", db="swan" )
cursor = connection.cursor()
cursor.execute( "SELECT * FROM Table1 " )
except MySQLdb.OperationalError, message:
errorMessage = "Error %d:\n%s" % (message[ 0 ], message[ 1 ] )
return
else:
self.data = cursor.fetchall()   
self.fields = cursor.description   
cursor.close()  
connection.close()

I agree, i am new to python, but i know php, and can run the same program in php.
Yah ! the code doesnot output anything, but atleast doesnot give any error when a similar program is made in php.
Swan is offline   Reply With Quote