php_beginner_83;10923585 wrote:I got it fixed.
I was missing a bracket, ')'
Thanks everyone for taking the time to help.
I see commonly people using the old mysql compiled driver, which has its own set of issues.
I keep suggesting to use PDO as it makes the script portable, runs with different databases just by changing the DSN, more unified, and less likely to have issues with data types.
Using your code as a frame of reference you would do PDO this way
try {
$dbh = new PDO("mysql:host=localhost;dbname=MyWebsite", "root", " ");
$result = $dbh->query("SELECT * FROM place ORDER BY ID desc limit 1");
$newID = $result['ID'] + 1;
$stmt = $dbh->prepare("INSERT INTO place (ID, Name) VALUES (?,?)");
$stmt->bindParam(1, $newID, PDO::PARAM_INT);
$stmt->bindParam(2, $_POST["name"], PDO::PARAM_STR);
$stmt->execute();
}
catch (PDOException $ex) {
die($ex->getMessage());
}