Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    16

    Unanswered: 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

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    $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? ***

  3. #3
    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 21:56.

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •