can anyone help me with the update please? I'm getting this error when trying to update.
Notice: Undefined index: description in C:\xampp\htdocs\RAPA_TOOL\projects.php on line 60
Notice: Undefined index: dtype in C:\xampp\htdocs\RAPA_TOOL\projects.php on line 66
Notice: Undefined index: targetrfs in C:\xampp\htdocs\RAPA_TOOL\projects.php on line 70
Notice: Undefined index: actualrfs in C:\xampp\htdocs\RAPA_TOOL\projects.php on line 71
Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 in C:\xampp\htdocs\RAPA_TOOL\projects.php:96 Stack trace: #0 C:\xampp\htdocs\RAPA_TOOL\projects.php(96): PDOStatement->execute(Array) #1 {main} thrown in C:\xampp\htdocs\RAPA_TOOL\projects.php on line 96
Here's my code. I checked the name of each input text and they're all correct but I'm not sure why some are undefined. On this update page, I also display the values of the selected project ID.
<?php
include 'include/connect.php';
if(isset($_POST['Update'])){
$projectid = $_POST['projectid'];
$projectname = $_POST['projectname'];
$description = $_POST['description'];
$systemsname = $_POST['systemsname'];
$phasename = $_POST['phasename'];
$status = $_POST['status'];
$classid = $_POST['classid'];
$dtypeid = $_POST['dtypeid'];
$domainid = $_POST['domainid'];
$kickoffdate = $_POST['kickoffdate'];
$endorseddate = $_POST['endorseddate'];
$targetrfs = $_POST['targetrfs'];
$actualrfs = $_POST['actualrfs'];
date_default_timezone_set("Asia/Taipei");
$today = date(("Y-m-d H:i:s"));
$phaseqry=$conn->prepare('SELECT phaseid FROM ref_project_phase where phasename=:phasename)');
$phaseqry->execute(['phasename'=>$phasename]);
$phaseid=$phaseqry->fetch(PDO::FETCH_ASSOC);
$updateqry="UPDATE project_details SET projectname=:projectname,
projectdescription=:description,
dtypeid=:dtypeid,
classid=:classid,
kickoffdate=:kickoffdate,
endorseddate=:endorseddate,
targetrfs=:targetrfs,
actualrfs=:actualrfs,
projectphaseid=:phaseid,
projectstatus=:status,
lastupdated=:today
WHERE projectid=:projectid";
$updateresult=$conn->prepare($updateqry);
$updateexec=$updateresult->execute(array(":projectname"=>$projectname,
":description"=>$description,
":dtypeid"=>$dtypeid,
":classid"=>$classid,
":kickoffdate"=>$kickoffdate,
":endorseddate"=>$endorseddate,
":targetrfs"=>$targetrfs,
":actualrfs"=>$actualrfs,
":phaseid"=>$phaseid,
":status"=>$status,
":today"=>$today,
":projectid"=>$projectid));
if($updateexec)
{
echo "<script>alert('Successfully Updated..')</script>";
echo "<script>window.open('projects.php', '_self')</script>";
}
else
{
echo 'Data Not Updated!';
}
}
?>
If someone can direct me to resolve the problem, that will be great. Thanks!