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

  • Home
  • SEARCH
  • 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 7602115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:19:50+00:00 2026-05-30T23:19:50+00:00

Question solved… silly mistake i have a little problem with my database update script

  • 0

Question solved… silly mistake

i have a little problem with my database update script (i’m using PDO and included a PDO class from here)

My logic:

Click on submit button calls “editClient.php” (need this cause i use AJAX):

<?php
// include clients class
require("../classes/clients.class.php");

// get vars & save them in $values array
$id = $_POST['id'];
$id = (int)$id;
$name = $_POST['name'];
$initial = $_POST['initial'];
$payment = $_POST['payment'];
$hourly_rate = $_POST['hourly-rate'];
if ($payment == 'payment-per-service') {
    $hourly_rate = "";
}
$active = $_POST['active'];

$values = array($name,$initial,$payment,$hourly_rate,$active,$id);

$client = new Client();
$client->editClient($values);
?>

My client.class.php (shorten):

<?php
// include database class
require_once('../../../lib/php/classes/database/database.class.php');

class Client {

    public function __construct() {
        $this->db = Database::get("default");
    }

    public function editClient($values) {
        if ($this->db->update("UPDATE clients SET name=?, initial=?, payment=?, hourly_rate=?, active=? WHERE cid=?",$values)) {
        } else {
            print "Updating failed";
        }
    }

    public function __destruct() {
        $this->db = null;
        unset($this->db);
    }   
}
?>

But every time i call my edit client script, i get this error:

Fatal error: Uncaught exception 'PDOException' with message 'PDO-Exception: 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 ')' at line 1' in /home/www/gopeter/collab/lib/php/classes/database/database.class.php:104 

Stack trace: 
#0 /home/www/gopeter/collab/lib/php/classes/database/database.class.php(127): Database->_query('UPDATE clients ...', Array, 'update') 
#1 /home/www/gopeter/collab/sites/clients/classes/clients.class.php(24): Database->update('UPDATE clients ...', Array) 
#2 /home/www/gopeter/collab/sites/clients/ajax/editClient.php(20): Client->editClient(Array) #3 {main} thrown in /home/www/gopeter/collab/lib/php/classes/database/database.class.php on line 104

But my SQL query looks correct?

  • 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-05-30T23:19:51+00:00Added an answer on May 30, 2026 at 11:19 pm

    You have an error in your SQL syntax near ‘)’

    What about looking at your query near )?

    It seems your coding style failed you.

    I will never understand a desire to stuff as much operators in one single line as possible.
    Look, isn’t it much more readable than your gigantic one line?

    $sql = "UPDATE clients SET name=?, initial=?, payment=?, hourly_rate=?, active=? 
            WHERE cid=?)";
    $res = $this->db->update($sql,$values);
    if ($res) {
    

    isn’t the wrong brace well spottable here?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The responses I've got to this question have solved the problem I had in
Problem solved, see below Question I'm working in Flex Builder 3 and I have
I have asked this question before and the problem was half solved in the
I have previously solved a similar problem in this question , where I asked
I understand the problem that OSGI solved thanks to this question.... What does OSGi
This is not really a question because I just solved the problem, but I
to those that may have read my previous question that got solved a couple
Question 1: (Solved) I'm facing an issue with class loader in Weblogic. I've a
Update: This question has been solved, so the buggy Firefox behavior will no longer
This follows this question which was solved using this answer . Long story short:

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.