Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Hello, I recently made a script and I would like to know how to make a page to add values into mySQL from browser ...
    I heard sth with global thing that makes it difficult so this code
    PHP Code:
    <?php
    include "config.php"//For mySQL Connection
    print "<form name='form1' method='post' action='add.php'>
    <input type='textfield' name='
    $url'>
    <input type='submit' value='Enter Data'>
    <input type='hidden' name='go' value='1'>
    </form>"
    ;

    if (
    $go=="1"){
    $sql "insert into TABLE values('', '$url', '0')";
    $result mysql_query($sql) or die("Failed: $sql");
    }
    ?>
    I didn't try this code but It won't work because of global things
    (Damn, I cant remember how they are called )

    Can somebody make the code so as to work with that global ?
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  2.  

  3. #2
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Code:
    <?php
    
    include "config.php"; //For mySQL Connection
    
    print "<form name='form1' method='post' action='add.php'>
    
    <input type='textfield' name='$url'>
    
    <input type='submit' value='Enter Data'>
    
    <input type='hidden' name='go' value='1'>
    
    </form>";
    
    
    
    if ($_POST['go']){
    
    $sql = "insert into TABLE values('', '$url', '0')";
    
    $result = mysql_query($sql) or die("Failed: $sql");
    
    }
    
    ?>
    Assuming you got $url from somewhere...
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  4. #3
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    I changed code and made add.php to a different page ...
    Now here is the code
    PHP Code:
    <?php
    include "config.php"//For mySQL Connection
    $url $_POST['url'];
    $sql "insert into wpclickcount values('','$url','0')";
    $result mysql_query($sql) or die("Failed: $sql");
    ?>
    But I get :
    Failed: insert into wpclickcount values('','test','0')
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations

  5. #4
    Member Black Vivi's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    75
    Member #
    1072
    Insert a space between "values" and the (
    Download Firebird now!

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Also, you should always explicitly state the colum names:
    Code:
    INSERT INTO table (column1, column2) VALUES (value1, value2)
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Senior Member Seldimi's Avatar
    Join Date
    Dec 2002
    Location
    Kozani, Greece
    Posts
    488
    Member #
    409
    Now it works, thank you ...
    - Webmaster's Planet . Greek Vortal For Webmasters ...
    - MyPortFolio - View My Creations


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:57 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com