943,676 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 352
  • Python RSS
Jan 28th, 2009
0

Reciving 3rd party info

Expand Post »
I have a third party sending me some infomaion. They say to use php $_post to recieve the information as follows

Python Syntax (Toggle Plain Text)
  1. <?php
  2. //include the database handling class
  3. include("mysqlclass.php");
  4.  
  5. //Assign POSTED variables
  6. $destination = $_POST['gwNumber'];
  7. $originator = $_POST['originator'];
  8. $message = $_POST['message'];
  9. $smsTime = $_POST['smsTime'];
  10. $timeZone = $_POST['timeZone'];
  11. $network = $_POST['network'];
  12. $id = $_POST['id'];
  13. $status = $_POST['status'];
  14.  
  15. //Create a new instance of the mysql class and write data to database
  16. $mysql = New mysql(0);
  17.  
  18. $sql = "
  19. INSERT INTO
  20. virtual
  21. (varOriginator, varDestination, varMessage, varTime, intTimeZone, varNetwork, intId)
  22. VALUES
  23. ('$originator', '$destination', '$message', '$smstime', '$timeZone', '$network', '$id')";
  24.  
  25. $mysql->query($sql);
  26. ?>

now i want to do this with python and have come up with

Python Syntax (Toggle Plain Text)
  1. #!/usr/bin/python
  2. import MySQLdb
  3. import cgi
  4. print "Content-type: text/html\n"
  5. # connect
  6. db = MySQLdb.connect(host = "localhost", user = "dfgdfgdfgdgfdfgdfgdfg passwd = "Udfgfdgdfgdfgdfdfgfdggsgsf", db = "adamplo1_UniProject")
  7. # create a database cursor
  8. cursor = db.cursor(MySQLdb.cursors.DictCursor)
  9.  
  10. #execute SQL select statement
  11.  
  12. form = cgi.FieldStorage()
  13.  
  14. destination = "sdfsdfsdf"
  15. originator = "sdfsdfsdf"
  16. message = form["message"]
  17. smsTime = "sdfsdfsdf"
  18. timeZone = "11"
  19. network = "sdfsdfsdf"
  20. ID = "1"
  21. status = "sdfsdfsdf"
  22.  
  23. sql = "INSERT INTO virtual (varOriginator, varDestination, varMessage, varTime, intTimeZone, varNetwork, intId) VALUES ('"+originator+"', '"+destination+"', '"+message+"', '"+smsTime+"', '"+timeZone+"', '"+network+"', '"+ID+"')"
  24. print sql
  25. print cursor.execute(sql)
  26.  

But nothing is being update. Is there another way to get the POST data?
Last edited by adam291086; Jan 28th, 2009 at 7:04 am.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
adam291086 is offline Offline
61 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Help me undestand...
Next Thread in Python Forum Timeline: Error: object has no attribute 'xxx'





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC