Python and PHP / MAMP -


i got python working mamp in terminal. below script works in terminal , prints should:

#!/usr/bin/python import mysqldb  db = mysqldb.connect (unix_socket = '/applications/mamp/tmp/mysql/mysql.sock',                     host = 'localhost',                     user = '*****',                     passwd = '****',                     db = 'database')  cur = db.cursor()   cur.execute("select * table")  row in cur.fetchall() :     print row[0]     print row[1] 

however not work when call via php:

exec("python test.py",$output); echo $output[0]  

i following php error

notice: undefined offset: 0 in /test.php on line 7

i created second test python script below:

import mysqldb print 'worked' 

and works expected - when have

import mysqldb  

commented out.

any suggestions?


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -