If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Vb6 to PhP to Mysql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-30-04, 09:39
Lord_Saroman Lord_Saroman is offline
Registered User
 
Join Date: Aug 2004
Posts: 16
Vb6 to PhP to Mysql

I am a beginner in PhP and mysql.
I am having trouble with connecting my vb6 program to my php script.

So far I have a textbox and a command button in vb6 . When I press the comand button I want to add the text into my MySql datbase.
the textbox name is: "username.text"

I need to know how to make my text field in vb6 connect to the php script.

my php script:

<?php
$dbh = mysql_connect ("localhost","bill","clinton") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mydatabase");

$query = "INSERT INTO clickdb (username) VALUES ('$username' )";
$result = mysql_query($query);
$rows = mysql_affected_rows($result);
echo "good";
?>

if this code is correct, then it might be my vb code I have trouble with, see it here:
Private Sub Command5_Click()
Downloaded = Me.itcHTTP.OpenURL(localhost & "signup.php?username=" & username.Text)
End Sub


when I use these codes it makes a new entry in my database but the fields are emty!?!? please help
Reply With Quote
  #2 (permalink)  
Old 12-01-04, 10:51
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,098
$dbh = mysql_connect ("localhost","bill","clinton") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mydatabase", $dbh);

try that
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #3 (permalink)  
Old 01-17-09, 20:41
DannyChaos DannyChaos is offline
Registered User
 
Join Date: Jan 2009
Posts: 1
Quote:
Originally Posted by Lord_Saroman
I am a beginner in PhP and mysql.
I am having trouble with connecting my vb6 program to my php script.

So far I have a textbox and a command button in vb6 . When I press the comand button I want to add the text into my MySql datbase.
the textbox name is: "username.text"

I need to know how to make my text field in vb6 connect to the php script.

my php script:

<?php
$dbh = mysql_connect ("localhost","bill","clinton") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mydatabase");


$query = "INSERT INTO clickdb (username) VALUES ('$username' )";
$result = mysql_query($query);
$rows = mysql_affected_rows($result);
echo "good";
?>

if this code is correct, then it might be my vb code I have trouble with, see it here:
Private Sub Command5_Click()
Downloaded = Me.itcHTTP.OpenURL(localhost & "signup.php?username=" & username.Text)
End Sub


when I use these codes it makes a new entry in my database but the fields are emty!?!? please help
New VB Code

Private Sub Command5_Click()
Downloaded = Me.itcHTTP.OpenURL("http://www.fullsiteurl.com/folder/signup.php?username=" & username.Text)
End Sub

New PHP Code

$username = $_GET['username'];
$query = "INSERT INTO clickdb (username) VALUES ('$username' )";
$result = mysql_query($query);
$rows = mysql_affected_rows($result);
echo "good";
?>

In the Downloaded variable of your VB, You need to take out "localhost" and put your full site URL, UNLESS the site is hosted off of your own computer/server.

Also, in your PHP, You're going to need to use the "GET" function to get from signup.php?username=User

Its not getting anything from that URL, Therefor, its inserting a blank value.

NOTE: Anything with bold text is what I added to your code. It should make it work.

If you want it to add multiple things to the database, just add more $variablename = $_GET['variable']; and edit the command1_click() code to

Downloaded = INetControl.OpenURL("http://www.site.com/folder/signup.php?un=" & Username.Text & "&variable=" & variable.Text

Last edited by DannyChaos; 01-17-09 at 20:56.
Reply With Quote
  #4 (permalink)  
Old 01-17-09, 22:29
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 480
This question should be in php or vb forum, though you are connecting to a mysql database that part is irrelevant for the code in question.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On