7 Replies Latest reply: May 2, 2012 5:58 PM by bregent RSS

    sql inserting new record error

    future-architect Community Member

      I am trying to simply insert a new record using sql.  here is my code:

       

      $sql="INSERT INTO question(topic, message, datetime)

                          VALUES('$topic', '$message', '$datetime'";

                          $result=mysql_query($sql);

                          if($result){

                                    $success = 1;

                          }

                          else {

                                    $error = "There was an error posting your question.  Please try again, or contact us.";

                          }

       

      When I try posting a new question, I get the error message.  It worked for me before.  I believe it has to do with the way that my SQL table is set up.  I have an ID field in the table, that is auto-incremented, as well as a primary key.  so not sure why it wouldn't be able to insert a new record there.  don't see anything that could really cause any conflict.  any thing else it could possibly be?

       

      EDIT:

       

      just noticed it had a cardinality of 3... how do i change this?