tags:

views:

129

answers:

1

I have a simple python CGI script where I query a MySQL database and then prints the result to the screen/webpage. My problem is that the "cursor.execute()" function returns a list of tuples. I use a simple for loop to iterate through this list and extract each tuple. This was working great until.....I got the bright idea to use jquery to make some eyecandy for the user. My whole script still work....except the for loop.

I have tried to (to my mind) everything, but for some reason when I do a loop it breaks everything. Could someone enlighten me please. I have also noticed that if I try and seperate my HTML formatting and python code by using function calls this also breaks the whole thing. By breaking I mean I get a server error(apache)

Below is the error via /var/log/httpd/error.log:

[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32]  , referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32]  , referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32]  , referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32]  , referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32] ^, referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32] SyntaxError, referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32] : , referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32] invalid syntax, referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32] , referer: http://test/index-test.html
[Tue Jan 12 14:56:25 2010] [error] [client 192.168.7.32] Premature end of script headers: userdata_submit.py, referer: http://test/index-test.html
A: 

It looks like you have a syntax error. In Python and Javascript, the code:

{referer: http://test/index-test.html}

is invalid. In Javascript, you'd have to write it like:

{referer: "http://test/index-test.html"}

and in Python (assuming "referer" is a key and not a variable) as:

{"referer": "http://test/index-test.html"}

It's hard to tell from your log, but you may have a similar problem with other keys in the same hash/dictionary prior to the referer key.

Chris S