Results 1 to 3 of 3

Thread: Newbie Help (updating mysql w/php)

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Newbie Help (updating mysql w/php)

    Hello friendly people,
    To start off I am a brand new beginner to database. I have been reading a book and trying to just pick up on a few things from tutorials and such.

    What I want to do is insert data into a database using a web form. I have been looking at some tutorials for example:
    http://www.w3schools.com/php/php_mysql_insert.asp

    But lets say I have a table called GYMINFO inside that table I have columns for GYMID, GYMNAME, ADDRESS1, CITY, STATE, ZIP, PHONE, FAX, ADDRESS2

    But in my webform I only want to collect GYMNAME and PHONE

    Below is part of my code but it does not seem that it is adding any data into the database... any help would be appreciated .... Thanks!

    $dbhandle = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");
    echo "Connected to MySQL<br>";
    mysql_select_db("gyms", $dbhandle);
    $sql="INSERT INTO GYMINFO (GYMNAME, PHONE)
    VALUES ('$_POST[Gname]','$_POST[Gnum]')";
    mysql_close($dbhandle);
    ?>

  2. #2
    Join Date
    Nov 2009
    Posts
    3

    Thumbs up hi

    The syntax for inserting into the database is correct but u need to execute the query and check the parameters passing to the query.

  3. #3
    Join Date
    Oct 2009
    Posts
    2
    Thanks, I did manage to get it to work, you know one lil thing needed to be done really and it changed everything

Posting Permissions

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