Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6836921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:24:50+00:00 2026-05-26T23:24:50+00:00

Here is the code: $the_question = $_POST[‘question’]; $the_answer = $_POST[‘answer’]; $dummy_num[] = $_POST[‘dummy_answer_1’]; $dummy_num[]

  • 0

Here is the code:

$the_question = $_POST['question'];
            $the_answer = $_POST['answer'];
            $dummy_num[] = $_POST['dummy_answer_1'];
            $dummy_num[] = $_POST['dummy_answer_2'];
            $dummy_num[] = $_POST['dummy_answer_3'];
            //Get Hidden Test ID and Q_order
            $test_id = $_POST['test_id'];
            $q_order = $_POST['q_order'];
            //Submit Question
            $data_submit_q = array (
                'type' => 1,
                'question' => $the_question,
                'done' => 1
            );
            $this->db->where('test_id', $test_id);
            $this->db->where('q_order', $q_order);
            $this->db->update('questions', $data_submit_q);
            $question_id = $this->db->insert_id();
            $time_created = date('Y-m-d H:i:s');
            //Submit Answer 
            $data_submit_a = array (
                'test_id' => $test_id,
                'question_id' => $question_id,
                'option' => $the_answer,
                'company_id' => $data['company']->id,
                'job_id' => $data['session_job_id'],
                'time_created' => $time_created
            );
            $this->db->insert('options', $data_submit_a);
            $answer_id = $this->db->insert_id();

            //Let question know that answer is right.
            $data_submit_qr = array (
                'answer_id' => $answer_id
            );

            $this->db->where('id', $question_id);
            $this->db->where('test_id', $test_id);
            $this->db->update('questions', $data_submit_qr);

Setting the answer id removes the value of the question id, then on updating the database the answer id has no value also. Even though it does right before.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:24:51+00:00Added an answer on May 26, 2026 at 11:24 pm

    The method $this->db->insert_id() retrieves the ID when performing database inserts (as the name hints).

    You’re using it after an update, that’s why your $question_id gives problems (I think it would be set to FALSE, but I don’t know for sure what does that method return when called on the wrong context). WHen you do your last update you use this as a WHERE condition, and if it is not set…

    It’s not that your second call to insert_id() wipes out the first, I suspect is more like the first one is already NOT SET (or FALSE)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code relating to the question: $theurl = trim($_POST['url']); $md5file = md5_file($theurl);
Here's some code (full program follows later in the question): template <typename T> T
The code in question is here: var $item = $(this).parent().parent().find('input'); What is the purpose
So, here's my question: Why won't the code in the first snippet work when
Quick question, What have I done wrong here. The purpose of this code is
I asked a question about same code but got lost in translation Here's what
Edit: The code here still has some bugs in it, and it could do
The code here is X++. I know very little about it, though I am
Here's the code from the ascx that has the repeater: <asp:Repeater ID=ListOfEmails runat=server >
Here's the code. Not much to it. <?php include("Spreadsheet/Excel/Writer.php"); $xls = new Spreadsheet_Excel_Writer(); $sheet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.