Im a student with a little bit of hiccup. So here i am
Username: epiz_29978322
http://bupcstudentmonitoringtool.rf.gd/prof/index.php
I tried to insert a data (student info) and it shows “error” and this is my code:
<?php session_start(); if(isset($_POST['enrolstud'])){ include "../db/dbcon.php" ; $profid=$_SESSION['id']; $studid = $_POST["studid"]; $name = $_POST["name"]; $sex = $_POST["sex"]; $id = $_POST["id"]; $check = mysqli_query($db,"SELECT * from stud_subject where stud_id='$studid' and subj_id='$id' ") or die("failed to query" .mysql_error()); $checkr = mysqli_fetch_array($check); if(is_array($checkr)) { header("location:course.php?id=$id#return"); }else{ $sql= "SELECT * FROM subjects WHERE subj_id='$id'"; $result = mysqli_query($db,$sql); $row = mysqli_fetch_assoc($result); $block=$row['year_sec']; $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz'; $code= substr(str_shuffle($permitted_chars), 0, 7); $insert="INSERT INTO `stud_subject` (`stud_id`,`stud_name`,`stud_block`,`subj_id`,`sex`,`subj_code`, `profid` ) VALUES ('$studid', '$name', '$block', '$id', '$sex', '$code', '$profid')"; if (mysqli_query($db, $insert)) { $last_id = mysqli_insert_id($db); $insert2="INSERT INTO `stud_grades` (`id`,`term` ) VALUES ('$last_id','1'),('$last_id','2')"; if(mysqli_query($db,$insert2)){ header("location:course.php?id=$id#done"); }else { echo $last_id;}}else { echo "error"; } } } I still don't know whether its a problem from php or mysql version. Please help. It works perfectly fine in my local server XAMPP but then i cant do it here. Thanks for the answer sirs!