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 9317027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:46:29+00:00 2026-06-19T02:46:29+00:00

My SQL PDO INSERT query does not appear to be inserting data into the

  • 0

My SQL PDO INSERT query does not appear to be inserting data into the table and does not return any error message stating why it can’t do this. Any idea as to what is going on?

UPDATE: I’m getting the following error message array(3) { [0]=> string(5) "00000" [1]=> NULL [2]=> NULL } after running var_dump($pdo->errorInfo())

$dept = $_POST['dept'];
$module_id = $_POST['moduleCode'];
$day_id = $_POST['day'];
$period_id = $_POST['period'];
$length_id = $_POST['length'];
$semester = $_POST['semester'];
$round = $_POST['round'];
$group_size = $_POST['group_size'];
$room_structure = $_POST['room_structure'];
$lecture_style = $_POST['lecture_style'];
$roomAllocation = $_POST['roomAllocation'];
$notes = $_POST['notes'];

// insert request into table

$sql = "INSERT INTO ts_request
                (dept_id,
                module_id,
                day_id,
                period_id,
                length_id,
                semester,
                round,
                group_size,
                room_structure,
                lecture_style,
                park_id,
                allocation
                notes)
                VALUES 
                (:dept,
                :module_id,
                :day_id,
                :period_id,
                :length_id,
                :semester,
                :round,
                :group_size,
                :room_structure,
                :lecture_style,
                :park,
                :allocation
                :notes)";
$stm = $pdo->prepare( $sql );
$stm->execute( array( ':dept' => $dept, 
                                            ':module_id' => $module_id,
                                            ':day_id' => $day_id,
                                            ':period_id' => $period_id,
                                            ':length_id' => $length_id,
                                            ':semester' => $semester,
                                            ':round' => $round,     
                                            ':group_size' => $group_size,                                                                                                                                                                               
                                            ':room_structure' => $room_structure,                                                                                                                                                                               
                                            ':lecture_style' => $lecture_style, 
                                            ':park' => $park,   
                                            ':allocation' => $roomAllocation,                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                            ':notes' => $notes ) );
$request_id = $pdo->lastInsertId();

// create allocation

$sql = "INSERT INTO ts_allocation
                (request_id,
                status)
                VALUES 
                (:request_id,
                :status";
$stm = $pdo->prepare( $sql );
$stm->execute( array( ':request_id' => $request_id, 
                                            ':status' => $status ) );
$allocation_id = $pdo->lastInsertId();

// insert weeks

$weeks = explode(",", $_POST["weeks"]);
for ($i = 0; $i < count($weeks); $i++) {
$sql = "INSERT INTO ts_week
                (request_id,
                allocation_id,
                week)
                VALUES 
                (:request_id,
                :allocation_id,
                :week)";
$stm = $pdo->prepare( $sql );
$stm->execute( array( ':request_id' => $request_id, 
                                            ':allocation_id' => $allocation_id,
                                            ':week' => $weeks[$i] ) );
}

// insert fac pref

$roomFac = explode(",", $_POST["roomFac"]);
for ($i = 0; $i < count($roomFac); $i++) {
$sql = "INSERT INTO ts_facpref
                (request_id,
                facilities_id)
                VALUES 
                (:request_id,
                :facilities_id)";
$stm = $pdo->prepare( $sql );
$stm->execute( array( ':request_id' => $request_id, 
                                            ':facilities_id' => $roomFac[$i] ) );
}

// insert room pref

$room_id = explode(",", $_POST["roomPref"]);
for ($i = 0; $i < count($room_id); $i++) {
$sql = "INSERT INTO ts_roompref
                (request_id,
                room_id)
                VALUES 
                (:request_id,
                :room_id)";
$stm = $pdo->prepare( $sql );
$stm->execute( array( ':request_id' => $request_id, 
                                            ':room_id' => $room_id[$i] ) );
}
var_dump($stm->errorInfo());
  • 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-06-19T02:46:30+00:00Added an answer on June 19, 2026 at 2:46 am

    Use var_dump($pdo->errorInfo()) AND $stm->errorInfo(); after every statement to see what errors PDO gives.

    P.s. you have errors in your queries. You miss last bracket:

    $sql = "INSERT INTO ts_allocation
                    (request_id,
                    status
                    VALUES 
                    (:request_id,
                    :status";
    

    and this

    $sql = "INSERT INTO ts_facpref
                    (request_id,
                    facilities_id,
                    VALUES 
                    (:request_id,
                    :facilities_id";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PDO::query to run the following SQL statement: INSERT INTO pages (template_id,user_id,page_default,page_internal_title,page_menu_text,page_nav_link,globalcontent_id,page_parent_id,page_order,page_active,page_show_in_menu,page_hide,page_created,page_updated,page_deleted,page_type) values
SQL statement: INSERT INTO order (`ORDER_ID`,`SALE_CODE`,`CREATED_AT`,`UPDATED_AT`) VALUES ('2646253286','HPHS20','2009-07-11 12:07:40','2009-07-11 12:07:40') Error: You have an
Do you see any issues with this MySQL query? It does not execute. Any
I am doing a signup form with an INSERT SQL query using PDO. After
I have very strange error with insert query to MySQL throught PDO. I want
I am trying to insert a serialize data into mySQL using PDO and I'm
I am reading a tutorial on how to insert and update data into a
public function insert($table, $data = array()) { $fieldnames = array_keys ( $data ); var_dump(implode
Im looking for efficient method for inserting CSV data into SQLite database on remote
In PHP, I want to insert into a database using data contained in a

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.