Results 1 to 2 of 2

Thread: syntax error.

  1. #1
    Join Date
    May 2013

    syntax error.

    Hi there,
    I can't find where I made a mistake, for years...
    $row = "INSERT INTO Student (Name, Surename, StudentID, Generation) VALUES ('$_POST[$student_data[0]]', '$_POST[$student_data[1]]', '$_POST[$student_data

    [2]]', '$_POST[$student_data[3]]')";

    This is report: Parse error: syntax error, unexpected '[', expecting ']' in
    Thanks in advance...

  2. #2
    Join Date
    May 2013
    Kansas City
    With the disclaimer that this is the worst possible coding practice, because you're wide open to SQL injection attacks if you write your code this way, here's the solution. You need to escape your strings. Like this.

    $row = "INSERT INTO Student (Name, Surename, StudentID, Generation) VALUES ('{$_POST[$student_data[0]]}', '{$_POST[$student_data[1]]}', '{$_POST[$student_data[2]]}', '{$_POST[$student_data[3]]}')";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center