Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9227059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:58:37+00:00 2026-06-18T04:58:37+00:00

I have a database and I am trying to update a row of it,

  • 0

I have a database and I am trying to update a row of it, but i keep getting this error. on a previous program i used the same function, so i can’t see what is going wrong and it’s driving me mad! If anyone can see anything or help me out it would be much appreciated!

Here is the update function:

public function update($member){
   if ($member == null){
      throw new Exception("Member ID Required");   }  

    $id = $member->getId();
    if ($id == null){
        throw new Exception("Member ID Required");
    }
    $sql = "UPDATE member SET
        firstName = :firstName,
        lastName = :lastName,
        dob = :dob,
        email = :email,
        gender = :gender,
        skillLevel = :skillLevel,
        Where id = :id";

    $params = array(
        'id' => $member->getId(),
        'firstName' => $member->getFirstName(),
        'lastName' => $member->getLastName(),
        'dob' => $member->getDOB(),
        'email' => $member->getEmail(),
        'gender' => $member->getGender(),
        'skillLevel' => $member->getSkillLevel(),
    );
      $stmt = $this->link->prepare($sql);
    $status = $stmt->execute($params);
    if ($status != true){
        $errorInfo = $stmt->errorInfo();
        throw new Exception("Could Not Add Member: " . $errorInfo[2]);
    }
    return $stmt->rowCount();
    }

Here is the edit page it is getting it’s data from

<?php

require_once('member.php');
require_once('MemberDAO.php');
require_once('editFormValidator.php');

$validator = new editFormValidator();

if ($validator->validate($_POST)){
$i = $_POST['memberID'];
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$dob = $_POST['dob'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$skillLevel = $_POST['skillLevel'];
$skillLevelString = implode(", ", $skillLevel);
$member = new Member ($i,$firstName, $lastName, $dob, $email, $gender,     $skillLevelString);
$dao = new MemberDAO();
$dao->update($member);
header ('Location: viewMember.php');
}
else{
require_once 'editMember.php';
}
?>

here is the full error:

Fatal error: Uncaught exception 'PDOException' with message '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 'Where id = '4'' at line 8' in /Applications/XAMPP/xamppfiles/htdocs/ChessClub/MemberDAO.php:115 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/ChessClub/MemberDAO.php(115): PDOStatement->execute(Array) #1 /Applications/XAMPP/xamppfiles/htdocs/ChessClub/edit.php(20): MemberDAO->update(Object(Member)) #2 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/ChessClub/MemberDAO.php on line 115
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:58:38+00:00Added an answer on June 18, 2026 at 4:58 am

    You have a superfluous comma here:

    skillLevel = :skillLevel,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run a UPDATE using REPLACE on my MySQL database. I have
I want get from database table row name but in it i get error.
I'm trying to call a row update from php to an mysql database. It
I have a database that I am trying to connect to through SQL Plus.
I have a database on an external server that I am trying to query.
I have a database based around a library system and I am trying to
I have a database which contains the link to audio files. I am trying
I have a database set up with email and password, I'm trying to use
I have a database table of zipcodes with their Lat/Longs. I'm trying to find
I'm trying to get to grips with regular expressions: I have a database connection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.