-3

I am very unsure at why I am getting such an error with my code

try {
$stmt = $connection->prepare("INSERT INTO table (path, title, era, information)
            VALUES (:path, :title, :era, :information)");
$stmt->bindParam(':path', $fname);
$stmt->bindParam(':title', $Name);
$stmt->bindParam(':era', $Era);
$stmt->bindParam(':descrip', $Description);

// insert row
$stmt->execute();
}
catch(PDOException $e) {
echo $e->getMessage();
}
echo "Upload Successful";
}

I have tried so many different options and I just cant fix the error

$fname=$_FILES["userfile"]["name"];
$Name =$_POST["name"];
$Era =$_POST["era"];
$Description =$_POST["info"];

these are the variables I used if that helps in solving my issue

Dave
  • 13
  • 4

1 Answers1

1

You define the values ':path, :title, :era, :information' in your prepare statement but try to set a value for the field ':descrip' later on. Because this field is not defined in the prepare call you get that error.

Use ':information' instead of ':descrip'.

Philipp Maurer
  • 2,480
  • 6
  • 18
  • 25
  • thank you for the help i Fixed that error but now i get this error SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table (path, title, era, information) VALUES ('a.png', 'asd', 'H' at line 1 – Dave Jan 05 '18 at 15:26
  • @dave TABLE is an SQL keyword and can therefore not be used without escaping it with backslashes. Using \`table` will work. – Philipp Maurer Jan 05 '18 at 15:36
  • @Dave help yourself, and give proper thanks (upvote and accept to close out this question). Your comment above is material for another question, dont stack new questions as comments. – YvesLeBorg Jan 05 '18 at 15:41