Im getting a:
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'classnum' cannot be null in /home/content/49/11554349/html/gb/dev/post.php on line 66
This is the php it refers too:
public function CheckIfEmptyTutor($class,$classnum,$studentyear){
if(empty($class) && empty($classname) && empty($studentyear)){
echo "All fields are requiered to create the post.";
return true;
}
else{
return false;
}
}
public function TutorPost($class,$classnum,$studentyear){
$stmt = $this->db->prepare("INSERT INTO tutors(class, classnum, studenyear) VALUES(?,?,?)");
$stmt->bindParam(1,$class);
$stmt->bindParam(2,$classnum);
$stmt->bindParam(3,$studentyear);
$stmt->execute();
if($stmt->rowCount() == 1){
echo "Successfully posted!";
}
//For testing purposes.
else{
echo "Something went wrong.";
}
}
Those are the functions I made, 1 is to check if the form is completely filled out, the other to actually post the data on the database.
And this is how im calling it in the html.
if(isset($_POST["submit"])){
$class = $_POST["class"];
$classnum = $_POST["classnum"];
$studentyear = $_POST["studentyear"];
$newpost = new UserPost();
if(!$newpost->CheckIfEmptyTutor($class,$classnum,$studentyear)){
$newpost->BookBoardPost($class,$classnum,$studentyear);
}
}
$classnamewith$classnumand enable error_reportingTutorPost( )callingBookBoardPost( )??