tags:

views:

76

answers:

1

I have a script returns a string:

http://mysite.com/script.php

PHP script:

$data = $_GET['q'];

$query = "SELECT * FROM `table` WHERE ID = '$data'";
$result = mysql_query($query);
$num = mysql_num_rows($result);

print $num;

I want to connect this script with VB, using this code

Dim con As String
con = "http://mysite.com/script.php?q=" & My.Settings.setq

Dim request = HttpWebRequest.Create(con)
request.Method = "GET"
Dim response = request.GetResponse()
Using reader = New StreamReader(response.GetResponseStream())
   msgbox(reader.ReadToEnd())
End Using

It is not working. How can i do that?

EDIT: I found solution

here

Dim uri As New Uri("http://site.com")
        Dim data As String = "data"
        If (uri.Scheme = uri.UriSchemeHttp) Then
  Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
            request.Method = WebRequestMethods.Http.Post
            request.ContentLength = data.Length
            request.ContentType = "application/x-www-form-urlencoded"

            Dim writer As New StreamWriter(request.GetRequestStream())
            writer.Write(data)
            writer.Close()

            Dim response As HttpWebResponse = request.GetResponse()
            Dim reader As New StreamReader(response.GetResponseStream())
            Dim tmp As String = reader.ReadToEnd()
            response.Close()
A: 

For some reason I couldn't comment on your post, only answer...

What are you using q for? You don't seem to be doing anything with it in your php. Do you want to get the result of the php script as part of your vB? We need a bit more information as to what you're trying to do.

Tim
i am using q for the mysql query. and i want to get the result of the php script as a msgbox in VB
Ahmet vardar