Results 1 to 8 of 8

Thread: mysql inserting blank fields from php form

  1. #1
    Senior Member
    Join Date
    Dec 2004
    Posts
    360
    Thanks
    27
    Thanked
    2 times in 2 posts
    • piggeh's system
      • Motherboard:
      • ASUS AiLife IP35
      • CPU:
      • Intel Q6600 G0
      • Memory:
      • OCZ 2x2GB DDR2 (5-4-4-18)
      • Storage:
      • 500GB Spinpoint
      • Graphics card(s):
      • Inno3D 8800GT
      • PSU:
      • Corsair HX520W
      • Case:
      • Antec 900 Case
      • Operating System:
      • Vista 64
      • Monitor(s):
      • Samsung 24" SM2494HS
      • Internet:
      • Virgin Cable

    mysql inserting blank fields from php form

    Apologies if this is a noobish mistake. Been working on learning PHP and just trying to insert some data into a mysql table, but whenever I do so, it inserts blank data. Anyone know where I'm going wrong please?

    PHP Code:
    <?php
    $user 
    $_POST["username"];
    $pwd $_POST["password"];
    $pwd2 $_POST["password1"];
    $email $_POST["email"];
    $inputcheck $_POST["inputcheck"];
    $error;

    $dbres mysql_connect('localhost','root');
    $select mysql_select_db("sitename"$dbres);

    $sql mysql_query"INSERT INTO ver_users
    (username, password, email)
    VALUES ('
    $user', '$pwd', '$email')
    "
    );
    Obviously the script is much bigger but the rest should not affect it (I hope!).

    The structure of table in mysql looks like thus:



    Also if I try to use
    PHP Code:
    $_POST["username"
    rather than the variables, it brings up an error regarding datatypes, yet the data submitted is a string of 5 or 6 characters long.

    Edit: If I settype() to a string it inserts a value of 1 for username (if input on form is, for examle, 'ssss'), so something is going wrong somewhere :/
    Last edited by piggeh; 23-06-2009 at 02:06 PM.

  2. #2
    Senior Member burble's Avatar
    Join Date
    May 2007
    Location
    Olney
    Posts
    1,138
    Thanks
    8
    Thanked
    90 times in 89 posts

    Re: mysql inserting blank fields from php form

    What do you get if you echo the variables out rather than insert into the DB? Do they have values or are they blank?

  3. #3
    Senior Member
    Join Date
    Dec 2004
    Posts
    360
    Thanks
    27
    Thanked
    2 times in 2 posts
    • piggeh's system
      • Motherboard:
      • ASUS AiLife IP35
      • CPU:
      • Intel Q6600 G0
      • Memory:
      • OCZ 2x2GB DDR2 (5-4-4-18)
      • Storage:
      • 500GB Spinpoint
      • Graphics card(s):
      • Inno3D 8800GT
      • PSU:
      • Corsair HX520W
      • Case:
      • Antec 900 Case
      • Operating System:
      • Vista 64
      • Monitor(s):
      • Samsung 24" SM2494HS
      • Internet:
      • Virgin Cable

    Re: mysql inserting blank fields from php form

    EDIT: Actually, they're blank, hmmm. I'm sure I tried an hour ago and it game me something.. strange.
    Last edited by piggeh; 23-06-2009 at 03:23 PM.

  4. #4
    Senior Member
    Join Date
    Dec 2004
    Posts
    360
    Thanks
    27
    Thanked
    2 times in 2 posts
    • piggeh's system
      • Motherboard:
      • ASUS AiLife IP35
      • CPU:
      • Intel Q6600 G0
      • Memory:
      • OCZ 2x2GB DDR2 (5-4-4-18)
      • Storage:
      • 500GB Spinpoint
      • Graphics card(s):
      • Inno3D 8800GT
      • PSU:
      • Corsair HX520W
      • Case:
      • Antec 900 Case
      • Operating System:
      • Vista 64
      • Monitor(s):
      • Samsung 24" SM2494HS
      • Internet:
      • Virgin Cable

    Re: mysql inserting blank fields from php form

    Sorry, sorted it, forgot to make variables available to a function :/

  5. #5
    HEXUS.social member Agent's Avatar
    Join Date
    Jul 2003
    Location
    Internet
    Posts
    19,185
    Thanks
    739
    Thanked
    1,614 times in 1,050 posts

    Re: mysql inserting blank fields from php form

    Get some validation on those variables
    Quote Originally Posted by Saracen View Post
    And by trying to force me to like small pants, they've alienated me.

  6. #6
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,168
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: mysql inserting blank fields from php form

    once again PHP lends itself to frankly awful programing prataces.

    This is why i recon it should just be allowed to die, like the relic of a bygone erea it is!
    throw new ArgumentException (String, String, Exception)

  7. #7
    HEXUS.social member Agent's Avatar
    Join Date
    Jul 2003
    Location
    Internet
    Posts
    19,185
    Thanks
    739
    Thanked
    1,614 times in 1,050 posts

    Re: mysql inserting blank fields from php form

    I was wondering when you'd pop up
    Quote Originally Posted by Saracen View Post
    And by trying to force me to like small pants, they've alienated me.

  8. #8
    Senior Member
    Join Date
    Dec 2004
    Posts
    360
    Thanks
    27
    Thanked
    2 times in 2 posts
    • piggeh's system
      • Motherboard:
      • ASUS AiLife IP35
      • CPU:
      • Intel Q6600 G0
      • Memory:
      • OCZ 2x2GB DDR2 (5-4-4-18)
      • Storage:
      • 500GB Spinpoint
      • Graphics card(s):
      • Inno3D 8800GT
      • PSU:
      • Corsair HX520W
      • Case:
      • Antec 900 Case
      • Operating System:
      • Vista 64
      • Monitor(s):
      • Samsung 24" SM2494HS
      • Internet:
      • Virgin Cable

    Re: mysql inserting blank fields from php form

    Quote Originally Posted by Agent View Post
    Get some validation on those variables
    I do have some validation, just didn't include all the code to save some space.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 10
    Last Post: 08-10-2008, 07:50 PM
  2. MySQL extension for PHP 5.2.3 not working
    By Jerrythafast in forum Help! Quick Relief From Tech Headaches
    Replies: 18
    Last Post: 13-06-2007, 08:03 PM
  3. Making PHP and MySQL Talk?
    By Dav0s in forum Software
    Replies: 4
    Last Post: 18-09-2005, 10:53 PM
  4. PHP and MySQL
    By Kezzer in forum Software
    Replies: 4
    Last Post: 28-10-2003, 02:59 PM

Posting Permissions

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