-1

I have this code to INSERT data into mysql table. Everything seems OK to me me because I just edited a code from another table with the same column names but this one gives error.

// Escape user inputs for security

$facultyid = mysqli_real_escape_string($link, $_REQUEST['facultyid']);

$coursename = mysqli_real_escape_string($link, $_REQUEST['coursename']);

$coursecode = mysqli_real_escape_string($link, $_REQUEST['coursecode']);

$level = mysqli_real_escape_string($link, $_REQUEST['level']);

$semester = mysqli_real_escape_string($link, $_REQUEST['semester']);

$year = mysqli_real_escape_string($link, $_REQUEST['year']);

$cee = mysqli_real_escape_string($link, $_REQUEST['cee']);

// attempt insert query execution 

$sql = "INSERT INTO courses (facultyid, coursename, coursecode, level, semester, year, cee)

VALUES ('$facultyid', '$coursename', '$coursecode', '$level' '$semester', '$year', '$cee')";

Any help?

Jalpesh Patel
  • 3,150
  • 10
  • 44
  • 68
Ashton
  • 1
  • 1
    I assume AlfredoEM's answer corrects your query. Please mark it as the answer. Next time, echo out your error message (to yourself) and correct the error where mysql tell you it is. If you don't know how to write echo the error, run your query in your database, it will tell you what went wrong. This question shows minimal effort in solving the problem yourself. – mickmackusa Feb 23 '17 at 03:14

1 Answers1

3

You are missing a coma (,) between '$level', '$semester'

VALUES ('$facultyid', '$coursename', '$coursecode', '$level', '$semester', '$year', '$cee')";
Alfredo EM
  • 2,029
  • 1
  • 14
  • 16