Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2009
    Location
    Texas
    Posts
    13
    Thanks
    3
    Thanked 1 Time in 1 Post

    Cannot INSERT into table

    What is wrong here?

    Code:
    $con = mysql_connect("localhost","db_user","password");
    if (!$con)  {  die('Could not connect: ');  }
    mysql_select_db("db_name", $con);
    
    $sql = "INSERT INTO polls ( name, question, instructions)
    VALUES ('$_POST[name]', '$_POST[question]', '$_POST[instructions]',)";
    
    if (!mysql_query($sql))
      {
      die('could not update');
      }
    echo "1 record added";
    It dies with 'could not update'


    EDIT: I found the problem. It was a syntax error. I have highlited it
    Last edited by RedMatrix; 04-03-2009 at 11:43 PM.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    if you have solved the problem please mark it as resolved
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    also get in the habit of using mysql_error() with your queries and you would have gotten an actual error returned.


  •  

    Posting Permissions

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