troubleshooting Question

[php|mysql] Issue with Insert Statement

Avatar of prileyosborne
prileyosborne asked on
PHPApache Web ServerMySQL Server
7 Comments3 Solutions461 ViewsLast Modified:
I have an insert statement that is not actually inserting anything into my database. It is part of a larger conditional statement that is checking for form data with GET, inserting that data to a data base and then selecting the data from the table that has the page data in it.

Below is the insert:
mysql_query ("INSERT INTO `foo` test_id, res_step_number, res_step_sub_number, res_step_outcome, res_step_notes, rest_test_taker) 
                    VALUES ('$_SESSION[test_id]','$_REQUEST[test_question]','$_REQUEST[test_question_sub]','$_REQUEST[question]','$_REQUEST[notes]','$_SESSION[test_taker]')");

And below is one example from my conditional statement with the insert:
elseif ($_REQUEST['test_question'] > 1 && $_REQUEST['test_question'] <= $_SESSION['total_q']) {

       // Load previous test data to the database
      mysql_query ("INSERT INTO `foo` test_id, res_step_number, res_step_sub_number, res_step_outcome, res_step_notes, rest_test_taker) 
                    VALUES ('$_SESSION[test_id]','$_REQUEST[test_question]','$_REQUEST[test_question_sub]','$_REQUEST[question]','$_REQUEST[notes]','$_SESSION[test_taker]')");

      // Get the next question
      $get_question = "SELECT test_id, step_number, step_number_sub, step_required, step_description, step_outcome, question_primary 
                      FROM create_test_questions
                      WHERE question_primary = '$_REQUEST[new_question_id]'
                      LIMIT 1";
      $result = mysql_query($get_question);
      $row = mysql_fetch_row($result);

      // Assign variables to populate question
      $test_id                          = $row['0'];
      $step_number             = $row['1'];
      $step_number_sub     = $row['2'];
      $step_required            = $row['3'];
      $step_description       = $row['4'];
      $step_outcome            = $row['5'];
      $test_question_id        = $row['6'];

      // Prepare variables for grabbing next question
      $test_question = $_REQUEST['test_question'] + 1;
      $new_question_id = $test_question_id + 1;

Let me know if you need anything else!
ASKER CERTIFIED SOLUTION
Beverley Portlock

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros