On Sep 29, 10:24 am, "tedpot...@gmail.com" <tedpot...@gmail.com> wrote: > Hi, > I'm trying to post data to a short test script in php I wrote. > The python code to do the post is > import httplib > > #server address > conn = httplib.HTTPConnection("localhost") > > #file location > conn.request("POST", "/programming/bots/test.php","&ted=fred") > r1 = conn.getresponse() > print r1.status, r1.reason > data1 = r1.read() > print data1 > conn.close() > print "new ok" > > The PHP script is > print"hello <br>"; > print $_POST["ted"]; > > Ted post
I can't speak to what is wrong with your current script - instead I would recommend the higher level urllib libraries: (Untested) import urllib2, urllib response = urllib2.open("http://localhost/programming/bots/test.php", urllib.urlencode({"ted": "fred"})) print response.read() response.close() ~Garrick -- http://mail.python.org/mailman/listinfo/python-list