How can I send a database query via HTTP from VBA code?

I need to use HTTP to send the following query from Access VBA code and retrieve the XML response.  Notice that the PHP script is performing the function of an ASP script.

http://www.myweb.com/Advisories.php?username=UserNameHere&password=PwdHere&query=SELECT%20%2A%20FROM%20tblAdvisories%20WHERE%20contact_id%20%3D%2012

(Note: the site name above is just a sample.  It does not really exist)

When I send this via a browser, the PHP script queries the database and sends the answer back in XML.  I need to see some sample VBA code that can send the query via HTTP and retrieve the response WITHOUT the browser.

This is extremely urgent. Please help!

Thanks
liberty1947Asked:
Who is Participating?
 
clockwatcherConnect With a Mentor Commented:
Here you go:

Function HTTPGet(url As String) As String

    Dim xmlhttp
    Dim retval As String
   
    Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
   
    xmlhttp.Open "GET", url, False
    xmlhttp.send
   
    retval = xmlhttp.responseText
   
    Set xmlhttp = Nothing
   
    HTTPGet = retval
   

End Function
0
All Courses

From novice to tech pro — start learning today.