In trying to run a very simple update query - I get no errors; however, the rows do not update either. Here is the code:
try {
require 'connect.php';
$id = $_POST['id'];
$rtn = $_POST['rtn'];
$project_name = $_POST['project_name'];
$staff_assigned = $_POST['staff_assigned'];
$current_status = $_POST['current_status'];
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
$building = $_POST['building'];
$department = $_POST['department'];
$department_contact = $_POST['department_contact'];
$facilities_contact = $_POST['facilities_contact'];
$device_count = $_POST['device_count'];
$project_overview = $_POST['project_overview'];
$sql = "UPDATE projects_list SET rtn=:rtn, project_name=:project_name, staff_assigned=:staff_assigned, current_status=:current_status, start_date=:start_date, end_date=:end_date, building=:building, department=:department, department_contact=:department_contact, facilities_contact=:facilities_contact, device_count=:device_count, project_overview=:project_overview WHERE id=:id";
$stmt = $db->prepare($sql);
$stmt->bindParam(':rtn', $rtn, PDO::PARAM_INT);
$stmt->bindParam(':project_name', $project_name, PDO::PARAM_STR);
$stmt->bindParam(':staff_assigned', $staff_assigned, PDO::PARAM_STR);
$stmt->bindParam(':current_status', $current_status, PDO::PARAM_STR);
$stmt->bindParam(':start_date', $start_date, PDO::PARAM_STR);
$stmt->bindParam(':end_date', $end_date, PDO::PARAM_STR);
$stmt->bindParam(':building', $building, PDO::PARAM_STR);
$stmt->bindParam(':department', $department, PDO::PARAM_STR);
$stmt->bindParam(':department_contact', $department_contact, PDO::PARAM_STR);
$stmt->bindParam(':facilities_contact', $facilities_contact, PDO::PARAM_STR);
$stmt->bindParam(':device_count', $device_count, PDO::PARAM_STR);
$stmt->bindParam(':project_overview', $project_overview, PDO::PARAM_STR);
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
}
catch (PDOException $stmt) {
echo $stmt->getMessage();
}
Seems so simple; however, I have tried many different suggestions from many similar answers on Stack and/or Google and can't seem to nail this down. Any help is appreciated!
EDIT: Connection code:
try {
$db = new PDO('mysql:host=localhost;dbname=projects;charset=utf8mb4', $user, $pass);
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>