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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:04:58+00:00 2026-05-20T11:04:58+00:00

So I have yet another problem, I am trying to get an AJAX script

  • 0

So I have yet another problem,

I am trying to get an AJAX script to work, but upon click the page will reload but fail to UPDATE the database field.

The code im using I have working for other similar scripts on the site but for some reason this one, using the same code doesnt work, the code used follows below;

HTML code to send the call to AJAX:

<input onClick="read('<? echo $id; ?>')" id="read" name="read" type="checkbox" value="1" style="position:relative; top:2px; width: auto">

The code to confirm user selection and send onto a form handling file:

function read(ID) {
    if(confirm('Are you sure you have read this carefully, you will not be alerted again "' + ID + '" ?')) {
        $.get('http://<? echo ROOT . ADMIN . INCLUDES; ?>formHandling.php', { read: ID }, function(data) {
            window.location.href = 'http://<? echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].""; ?>';
        });
    }
    return false;
}

Lastly the code to handle the SQL query:

if (isset($_GET['read'])) {

    // Pass the GET data and associate them to variables
    $read = trim($_GET['read']);

    $query  = "UPDATE cms_motd SET read='$read' WHERE id='1'";
    $result = mysql_query($query)or die("Database query died: " . mysql_error());

    unset($_GET['readConfirm']);
}

Thanks in advance for all that help.

Regards,

Dan.

  • 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-20T11:04:59+00:00Added an answer on May 20, 2026 at 11:04 am

    Don’t you mean:

    $query  = "UPDATE cms_motd SET read='1' WHERE id='$read'";
    

    Instead of:

    $query  = "UPDATE cms_motd SET read='$read' WHERE id='1'";
    

    Edit:

    I don’t know if it is a copy&past error:

    $result = mysql_query($query);or die("Database query died: " . mysql_error());
    

    Needs to be:

    $result = mysql_query($query) or die("Database query died: " . mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After getting a helpful answer here , I have run into yet another problem:
I've got yet another deployment problem. What I have: little Windows Forms application that
I am trying to get a guest book to work using PHP. I have
I have yet another issue which the answer is eluding me. I wish to
I've looked around but have yet to find a great solution the the following
I have searched online for a solution, but have yet to find one that
Okay this may be a simple question but I have yet to come with
This is a fairly common problem to which I have yet to find an
I've tried Googling and searching stackoverflow, but have yet to find a solution too
I have a webpage that makes an ajax call to get some data. That

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.