0

I am trying to insert student exam answers to a table online_exam_marks. I stored $_POST values after ensuring that $_POST value is not empty and if they empty I just set it to $a = '0' to different variables i.e $a,$b,...

$stu_id = $_SESSION["id"];

$sql = "INSERT INTO online_exam_marks (stu_id , 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) VALUES ( '$stu_id' ,'$a', '$b','$c','$d','$e','$f','$g','$h','$i','$j')";

if(mysqli_query($con,$sql))
{
    render("success.php");  
}
else echo "error";

when this executes it always returns prints error. please help.

3
  • Have you tested the actual query in phpmyadmin to confirm that the query itself is correct? If it fails there, it will fail in a php script. How was the table constructed in the database? What are the constraints, if any, on the table? For example, if the stu_id column has a unique constraint, it won't allow a second row to be added with that same ID. Posting the phpmyadmin screen showing the table setup and constraints might help.
    – Cliff B
    Dec 8 '16 at 5:11
  • actually the table is empty and I am inserting first row of the table
    – AshrafNmd
    Dec 8 '16 at 5:44
  • Did you test the query using the phpmyadmin interface?
    – Cliff B
    Dec 8 '16 at 5:45
0

This is solved after changing column names to 1,2,3... Thanq guys for help

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .