Reciving 3rd party info

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 58
Reputation: adam291086 is an unknown quantity at this point 
Solved Threads: 0
adam291086 adam291086 is offline Offline
Junior Poster in Training

Reciving 3rd party info

 
0
  #1
Jan 28th, 2009
I have a third party sending me some infomaion. They say to use php $_post to recieve the information as follows

  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

  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC