Friday, 15 August 2014

mysql - SQL PDO INSERT query not entering values into table -



mysql - SQL PDO INSERT query not entering values into table -

my sql pdo insert query not appear inserting info table , not homecoming error message stating why can't this. thought going on?

update: i'm getting next 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 table $sql = "insert 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 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"]); ($i = 0; $i < count($weeks); $i++) { $sql = "insert 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"]); ($i = 0; $i < count($roomfac); $i++) { $sql = "insert 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"]); ($i = 0; $i < count($room_id); $i++) { $sql = "insert 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());

use var_dump($pdo->errorinfo()) , $stm->errorinfo(); after every statement see errors pdo gives.

p.s. have errors in queries. miss lastly bracket:

$sql = "insert ts_allocation (request_id, status values (:request_id, :status";

and this

$sql = "insert ts_facpref (request_id, facilities_id, values (:request_id, :facilities_id";

mysql pdo

No comments:

Post a Comment