看板 Python 關於我們 聯絡資訊
我寫了下面這隻python程式要來獲得MySQL裡面的資料 #!/usr/bin/python #coding:utf-8 import MySQLdb conn = MySQLdb.connect(host="x.x.x.x",user="xx",passwd="xx",db="xx") cursor = conn.cursor() cursor.execute("select * from rule") result = cursor.fetchall() print "Content-Type: text/html" # HTML is following print # blank line, end of headers print "<html>" print "<head>" print "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" print "<title> Python import MySQLdb</title>" print "</head>" print "<body>" for record in result: print record[0] print "</body>" 如果我直接在 console 裡面 python sql.py的話可以正確獲得資料 但是放到網站上面想要作成cgi來用的時候就會出現 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log 錯誤訊息蠻多的,我貼在這邊。 http://sites.google.com/site/iwhiori/home/python-mysqldb-error 總而言之我想要用 python 在網頁上面讀取資料庫資料 咕狗了超過八個小時!!還是找不到答案... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.174.37.8
sbrhsieh:錯誤訊息不是說了沒有權限存取檔案夾:/nonexistent? 07/04 20:27
shaopin:你有權限execute和讀DB,user of CGI沒有... 07/05 01:30
magicallove:那誰是use of CGI ? 07/05 01:36
iincho:通常是apache... 07/05 10:48