text: I am trying to pass a PHP variable into my python script. However I keep getting the following error.
  Traceback (most recent call last):
  File "alarmTest.py", line 29, in <module>
  currUID = int(sys.argv[1])
  IndexError: list index out of range
  My PHP excerpt:
  My Python excerpt:
  Code: Select all
  $command = system("'python alarmTest.py' > /dev/null 2>&1 &").$UID; $output1 = shell_exec($command); echo $output1;
  Code: Select all
  import sys import os currUID = int(sys.argv[1]) print (currUID) sql_Query = ("SELECT * FROM oh_users WHERE id = %s" % currUID) cursor = mySQLconnection.cursor() cursor.execute(sql_Query) telNo = int(cursor.fetchone()[0]) # parse from tuple to int
  If I change the index in the python code to - currUID = int(sys.argv[0]) - I get following Error code:
  alarmTest.py
  ('Error while connecting to oh_Database-:', ProgrammingError(1054, "1054 (42S22): Unknown column 'alarmTest.py' in 'where clause'", u'42S22'))
  So It seems it is maybe just the way I am trying to pass the Var?
  Any help at all is much appreciated
  PS. $UID (in the php) is a session variable. I am not sure if that makes a difference? But I can access it in the PHP script so should still be able to pass it?
  Bee