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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:37:36+00:00 2026-05-18T11:37:36+00:00

I have a simple page in a PHP/MySQL web application that lets admin users

  • 0

I have a simple page in a PHP/MySQL web application that lets admin users edit HTML template e-mails (stored in the database). Essentially to edit a template the user types into a textarea and submits a form which posts back to the same page.

When the form is submitted, a PHP function gets called that updates the record in the database by means of a parameterised query to a MySQL stored function.

Finally the record is retreived from the database and the information is displayed on the page – this step also happens when the page is being displayed for the first time.

The problem I am having is that although the record is being updated in the database before it is retrieved for display, the page is still displaying the old data from before the update when it is rendered. Other things on the page, such as the banner message saying the update was successful DO get updated, so I don’t think it’s a browser caching problem. Adding the line: sleep(1); after the record update solves the problem so the page shows the updated record, but for performance reasons this isn’t ideal, and I don’t understand why this problem is happening in the first place.

Here is the PHP code from the top of the page:

require_once('includes/global.php');
require_once('includes/emailtemplateutils.php');

$strMsg = '';

$lngEmailTemplatePK = ConvertToString($_GET['key'], 0);

if (ConvertToString($_POST['hdnSave']) == '1')
{

    $strFromAddress = ConvertToString($_POST['txtFromAddress']);
    $strSubjectLine = ConvertToString($_POST['txtSubjectLine']);
    $strBodyHTML = ConvertToString($_POST['txtBodyHTML']);

    if (EmailTemplate_Update($lngEmailTemplatePK, $strFromAddress, $strSubjectLine, $strBodyHTML))
    {

        $strMsg = FormatMsg('E-mail template updated.');

    }
    else
    {

        $strMsg = FormatErrorMsg('Could not save e-mail template!');

    }

}

$objEmailTemplate = EmailTemplate_Display($lngEmailTemplatePK);

This is the code of the EmailTemplate_Update() function which actually does the update:

function EmailTemplate_Update($lngEmailTemplatePK, $strFromAddress, $strSubjectLine, $strBodyHTML)
{

    $objConn = new mysqli(cstrGlobal_DbServer, cstrGlobal_DbUsername, cstrGlobal_DbPassword, cstrGlobal_DbCatalog);

    if (mysqli_connect_errno())
    {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }

    $strQuery = "SELECT srf_EmailTemplate_Update(?, ?, ?, ?)";

    $objStmt = $objConn->prepare($strQuery);

    $objStmt->bind_param('isss', $lngEmailTemplatePK, EmptyToNull($strFromAddress), EmptyToNull($strSubjectLine), EmptyToNull($strBodyHTML));

    $objStmt->execute();

    $objStmt->bind_result($lngRetVal);

    $objStmt->fetch();

    $objStmt->close();

    $objConn->close();

    return $lngRetVal == 1;

}

The function for retrieving the record for display is a bit more convoluted but essentially just brings back the record as an object using mysqli fetch_object()

Please help.

  • 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-18T11:37:36+00:00Added an answer on May 18, 2026 at 11:37 am

    I eventually managed to solve this problem, though not in the way I would have planned. I managed to break the Linux install on the server due to various dependency issues after I attempted to upgrade MySQL and PHP. I ended up having to rebuild the server from scratch.

    The code in my original question now works as expected. I suspect the issue may have been that the InnoDB setting lines were commented out in the my.cnf file of the original MySQL installation.

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

Sidebar

Related Questions

I have a simple web page that till now didn't need any login. It
Working on a web based buying and selling application with PHP MySQL where users
I have built a small web application in PHP where users must first log
I have a simple cart page that displays items that are in someones cart,
I have a simple html page with a div. I am using jQuery to
I have a very simple ASP.Net page that acts as a front end for
I've been developing a web application with PHP and MySQL. The other day, I
I am part of a team creating a web application using PHP and MySQL.
I have a php web application where certain data changes on a weekly basis
I've got a simple website using plain HTML/CSS to display and PHP/MySQL for data

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.