I am having a difficulty of why inserting data in second table is not "inserting" when in the first table it is "inserted".
controller.js
$scope.addStudent = function(student){
var data {
firstName: student.firstName,
gFirstName: student.firstName
};
$http.put("php/students/addStudent.php",data).then(function(response){
console.log(response);
});
}
addStudent.php
<?php
include("../../connection.php");
$data = json_decode(file_get_contents("php://input"));
$firstName = $data->firstName;
$gFirstName = $data->gFirstName;
$q = "INSERT INTO tblstudents (firstName) VALUES ('$firstName')";
$db->query($q);
$r = "INSERT INTO tblparents (firstName) VALUES ('$gFirstName')";
$db->query($r);
?>
I just added the $r query
thinking that it will work the way I expected to work but it's not working the way I expected. No data was being inserted into the table tblparents
, while on table tblstudents
data is inserted normally.
connection.php
<?php
header("Cache-Control: no-cache, must-revalidate");
$db = new PDO("mysql:host=localhost;dbname=myDB","root","");
?>