|
-
Aug 21st, 2007, 12:03 PM
#1
Thread Starter
Addicted Member
query remote sql
I want to get information from remote mysql database from my VB6 Application.
I want to use PHP, because mysql database don't accept remote access.
I've seen an Example and then I try but not seccessfull.
Can anybody help me?
Hare i want to check the db for, is there available my name? yes or not Just It.
VB Code:
sql = "Select * FROM usrtbl Where name='" & Text1.txt & "'"
path = "http://localhost/name.php?sql="
myPath = path & sql
MyIP = Inet1.OpenURL(myPath)
Text1.Text = MyIP
PHP Code:
<?php
$host="localhost";
$user="root";
$db="ant";
$link=mysql_connect($host,$user) or die ("Couldnot connect".mysql_error());
if ($link) {
mysql_select_db($db) or die ("Couldn't".mysql_error());
}
$result=mysql_query('sql');
$num_rows=mysql_num_rows($result);
if ($num_rows > 0)
{
print"1";
}else{
print"0";
}
?>
-
Aug 21st, 2007, 12:38 PM
#2
Re: query remote sql
What is it that you want help in? VB6 or PHP?
-
Aug 21st, 2007, 12:39 PM
#3
Hyperactive Member
Re: query remote sql
Hi r_amin;
I am a bit baffled by your request.
I want to get information from remote mysql database from my VB6 Application.
If the five lines of code you've shown are all you are working with then you need to do more work. Where is your connection string? You say you want to connect to a remote database but you use localhost???
What is the purpose of Text1.Text in your sql = statement and it's relationship to Text1.Text = MyIP in the last statement
Does MyIP = Inet1.OpenURL(myPath) return an IP address like 192.168.1.1?
I want to use PHP, because mysql database don't accept remote access.
Could you provide additional detail, as far as I know you can connect remotely to a MySQL database.
I've seen an Example and then I try but not seccessfull.
What exactly are you trying to do?
Can anybody help me?
Please provide more information.
-
Aug 21st, 2007, 01:59 PM
#4
Thread Starter
Addicted Member
Re: query remote sql
 Originally Posted by Hack
What is it that you want help in? VB6 or PHP?
Both.
I'm trying VB6 + PHP.
please read, I think, I've told everything detailed.
actually I need to know, Is there my name in the database? Yes or not.
when any host not support remote access, So I need another way.
-
Aug 21st, 2007, 01:59 PM
#5
Thread Starter
Addicted Member
Re: query remote sql
Hi LinXG
Yes, this is localhost. This is my practice. But, I want to apply it to remote host.
''Text1.Text'' is used to enter a name. What i want to find.
MyIP just a string veriable
Yes, I can connect remotely to a MySQL database, But not any Database anytime. It has restriction.
-
Aug 21st, 2007, 02:13 PM
#6
Thread Starter
Addicted Member
Re: query remote sql
as we can know IP address
Dim MyIP As String
MyIP = Inet1.OpenURL("http://pchelplive.com/ip.php")
Text1.Text = MyIP
Text1.Text = Replace(Text1, Chr(10), "")
-
Aug 21st, 2007, 03:10 PM
#7
Hyperactive Member
Re: query remote sql
Hi r_amin
I'm still not sure what you're after but here is a code sample that shows how to connect a MySQL database and retrieve some data using VB6.
Code:
Dim MyRecordSet As ADODB.Recordset
Dim mySQL_String As String
Dim StrConn as String
' **** Use of one these statements, comment out the other ****
StrConn = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;" ' Localhost connection
StrConn = "Driver={MySQL ODBC 3.51 Driver};Server=data.domain.com;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;" ' Remote connection
mySQL_String = "Select * FROM usrtbl Where name='" & Text1.txt & "'"
Set MyRecordSet = New ADODB.Recordset
MyRecordSet.Open mySQL_String, StrConn, , , adCmdUnknown
If MyRecordSet.EOF = False then
' If the recordset is not empty do something
Text2.text = MyRecordSet("SomeFieldName") ' example - show a field in a text box
else
' If the recordset is empty do this instead
end if
MyRecordSet.Close
-
Aug 21st, 2007, 03:46 PM
#8
Re: query remote sql
 Originally Posted by LinXG
Hi r_amin
I'm still not sure what you're after but here is a code sample that shows how to connect a MySQL database and retrieve some data using VB6.
Except that.....
 Originally Posted by r_amin
I want to use PHP, because mysql database don't accept remote access.
So connecting directly via vb6 ain't gonna cut it...
The problem is the SQL statement itself.... in a nutshell, you are sending it as is, but using the QueryString to send it.... It has to be URL encoded first... then from the PHP site, retrieved using the GET[] vars, and DeURLEncoded. I know there's a function in PHP that will undo the url encoding....I'm reasonably sure there isn't a built-in VB6 way to do it, but there are components out there that can do it. Search for VB6 URLEncoding or Visual Basic URLENcoding, and other variations, something is bound to turn up.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|