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 8753113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:21:54+00:00 2026-06-13T13:21:54+00:00

I am trying to update a database, here is my code if (isset($_GET[‘placeorder’])) {

  • 0

I am trying to update a database, here is my code

if (isset($_GET['placeorder']))
{
    include 'includes/db.php';

    try
    {
    $newBalance = $_POST['balance'] + $_POST['oldbalance'];
    $sql = 'UPDATE customer SET
            balance = :balance
            WHERE id = :id';
    $s = $pdo->prepare($sql);
    $s->bindValue(':balance', $newBalance);
    $s->execute();
    }
    catch (PDOException $e)
    {
        $error = 'Could not add the new balance for the customer' . $e->getMessage();
        include  'result.php';
        exit(); 

    }
    header('Location: .');
    exit();

What I am trying to do is update the balance for a customer that is coming from a form that was submitted. I am able to get the value in the code all the way up to where I get to $s->execute(); if I try to echo the value, which is $newBalance, it will not show after that line is executed, the page goes blank. Something is happening in the execute statement. $s->execute() that it does not allow my code to proceed. Any idea? Am I using the PDO class the wrong way. It is not getting to the “catch” statement. Any help would be great. The end result is that the page returns to where it started with the updated balance.

  • 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-13T13:21:55+00:00Added an answer on June 13, 2026 at 1:21 pm

    You are only binding a value to the balance, not the id, you need a line like:

    $s->bindValue(':id', $id);
    

    It would be a good idea to make sure that $_POST['balance'] and $_POST['oldbalance'] are set as well before using them in your query:

    $balance = isset($_POST['balance'])? $_POST['balance'] : 0;
    $oldbalance = isset($_POST['oldbalance'])? $_POST['oldbalance'] : 0;
    $newbalance = $balance + $oldbalance;
    

    If you aren’t getting an error, you likely don’t have error reporting on, you can enable it by adding error_reporting(E_ALL); to the top of your page.

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

Sidebar

Related Questions

I'm trying to update a database using html form + jquery + php When
I'm trying to update a database from my program in C#. Here is my
I am trying to update a record in a database. The code is meant
I am trying to update a database with values from a csv file, the
I am trying to update the database to show that something has been uploaded.
I'm making a 'post text' app and trying to update my database with name
I'm trying to update a field in the database to the sum of its
I'm trying to update a row in my database but it's not running. Below
I'm trying to update the records in an Access database where the column Group
So I'm trying to update an object in my MS SQL 2005 database using

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.