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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:08:17+00:00 2026-06-18T16:08:17+00:00

I am trying to update one of my row with PHP using MySQLi and

  • 0

I am trying to update one of my row with PHP using MySQLi and if I refresh PHPMyAdmin less than 1 second after update it’s sucessfull but if I only check the data 2 seconds+ after the update it doesn’t update.

For exemple:

'UPDATE orders SET MachineID = '.$id.' WHERE OrderID = '.$OrderID.
                   'AND ProductID = '.$ProductID

Does not work unless I refresh quickly but…

'UPDATE orders SET MachineID = 2 WHERE OrderID = 4 AND ProductID = 12'

Will work no matter how long after I refresh. (Those are the data I normaly use to test.)

So I though it would be my variables, but I’m using them almost 10 times before this part of the code in other queries and it works perfectly.

  • I tried to trim() the variable and it did not help.
  • I also tried to use mysqli_real_escape_string() with no success.
  • mysqli_error() is not giving me anything.
  • mysqli_affected_rows() is giving me “1” which is what it is suppose to be.
  • And the weird part is if I execute ‘SELECT MachineID FROM orders WHERE OrderID = 4 AND ProductID = 12’, it gives me the updated answer even if phpMyAdmin does not update the data.

There is no other code after this, so nothing that could “reverse” the update.

A normal “test” ouput looks like this:

Edit: This it what the browser outputs.

ID: "2" //$id
OrderID: "4" //$OrderID
ProductID: "12" //$ProductID
UPDATE orders SET MachineID = 2 WHERE OrderID = 4 AND ProductID = 12 //Query
boolean true //Result var_dump
1 //Number of rows affected
2 //Machine ID

Note: The quotes are not part of the variables.

Edit: This is the PHP code

$query = 'UPDATE orders SET MachineID = '.$id.' WHERE OrderID = '.$OrderID.' AND ProductID = '.$ProductID;          
echo 'ID: "'.$id.'"<br/>
     OrderID: "'.$OrderID.'"<br/>
     ProductID: "'.$ProductID.'"<br/>'.$query.'<br/>';

$res = $db->query($query);
var_dump($res);

echo mysqli_affected_rows ($db).'<br/>';   
$result = $db->query('SELECT MachineID FROM orders WHERE OrderID = 4 AND ProductID = 12');      
$result = $result->fetch_array();
echo $result[0];

I really don’t understand why it would work in the file and after a quick refresh but not if it takes to long to retreive the data. It’s like it would reset after a certain amount of time if it’s not fetch.

I’ve been working on this for almost 2 days now I have no idea why it’s not working. This is some pretty simple SQL query.

Edit: I’ve look into MySQL binary logs and it seems that I’m updating it back to 1 every time. The only way this could be happening is if the file would run twice, but if it runs twice why would the output be there only once ?

Edit: Ok, so it seems like the problem comes from Google Chrome. I’ve tested it on IE and it works. For some reason Chrome would be running the file twice.

  • 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-18T16:08:18+00:00Added an answer on June 18, 2026 at 4:08 pm

    Ok so I was able to find the problem and fix it.

    Problem:
    The problem was the famous “favicon” bug with Chrome which is trying to get the icon even if it doesn’t exist, therefore the file is called twice.

    Fix:
    Since this file was meant to be called through an Ajax call the bug is not triggered since Chrome will not try to look for the “favicon”. I basicly fixed the bug by testing it how it was supposed to be run and not just testing the file itself.

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

Sidebar

Related Questions

hi i'm trying to update two different tables with one trigger but i keep
I am using SSIS 2008 and am trying to update one column in my
I'm trying to update one value of a compound primary key from within the
I'm trying to update one table based on values in another table. What's wrong
I am trying to update a label from one form to another. the code
I'm trying to update the comments column in one table (Entries), when a new
I am trying to update the list of items in one combobox2 depending on
I'm trying to update the price of products in one table (ps_product) from another
I have one user (only one, all the others are fine) trying to update
I'm trying to submit an update of an existing application on behalf of one

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.