473,761 Members | 8,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stale data when requerying MySQL w/PHP?

I've got this weird problem. I'm connecting to MySQL via PHP,
querying a particular table, closing the connection then parsing and
displaying the results. I then modify the table but when I reload the
PHP page, the output does not reflect this change.

Viz:

----[SQL query]----
mysqlselect * from users;
+----------+
| username |
+----------+
| jayds |
+----------+

----[web page output]----
Array ( [username] =jayds )

----[SQL query]----
mysqlinsert into users values ("wes");
Query OK, 1 row affected (0.00 sec)

----[reloaded web page output]----
Array ( [username] =jayds )

....and a rechecking of the db reflects that "wes" IS, in fact, in the
table.

This is the code I'm using (minus the parts that parse and print the
resource):

----[%begin%]----

$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error
connecting to mysql');

mysql_select_db ('wes') or die('Could not select database');

$query = "SELECT * FROM users";
$resource = mysql_query($qu ery) or die('Query failed: ' .
mysql_error());
mysql_close($co nn);

----[%end%]----

Any ideas on why I'm seeing stale data?

Thanks much in advance!,
Jason
Sep 28 '08 #1
4 2349
bodhiSoma wrote:
I've got this weird problem. I'm connecting to MySQL via PHP,
querying a particular table, closing the connection then parsing and
displaying the results. I then modify the table but when I reload the
PHP page, the output does not reflect this change.

Viz:

----[SQL query]----
mysqlselect * from users;
+----------+
| username |
+----------+
| jayds |
+----------+

----[web page output]----
Array ( [username] =jayds )

----[SQL query]----
mysqlinsert into users values ("wes");
Query OK, 1 row affected (0.00 sec)

----[reloaded web page output]----
Array ( [username] =jayds )

...and a rechecking of the db reflects that "wes" IS, in fact, in the
table.

This is the code I'm using (minus the parts that parse and print the
resource):

----[%begin%]----

$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error
connecting to mysql');

mysql_select_db ('wes') or die('Could not select database');

$query = "SELECT * FROM users";
$resource = mysql_query($qu ery) or die('Query failed: ' .
mysql_error());
mysql_close($co nn);

----[%end%]----

Any ideas on why I'm seeing stale data?

Thanks much in advance!,
Jason
Caching - either by your browser or a system between your web server and
your client?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Sep 28 '08 #2
bodhiSoma wrote:
I've got this weird problem. I'm connecting to MySQL via PHP,
querying a particular table, closing the connection then parsing and
displaying the results. I then modify the table but when I reload the
PHP page, the output does not reflect this change.

Viz:

----[SQL query]----
mysqlselect * from users;
+----------+
| username |
+----------+
| jayds |
+----------+

----[web page output]----
Array ( [username] =jayds )

----[SQL query]----
mysqlinsert into users values ("wes");
Query OK, 1 row affected (0.00 sec)

----[reloaded web page output]----
Array ( [username] =jayds )

...and a rechecking of the db reflects that "wes" IS, in fact, in the
table.

This is the code I'm using (minus the parts that parse and print the
resource):

----[%begin%]----

$conn = mysql_connect($ dbhost, $dbuser, $dbpass) or die ('Error
connecting to mysql');

mysql_select_db ('wes') or die('Could not select database');

$query = "SELECT * FROM users";
$resource = mysql_query($qu ery) or die('Query failed: ' .
mysql_error());
mysql_close($co nn);

----[%end%]----

Any ideas on why I'm seeing stale data?

Thanks much in advance!,
Jason
You performed an INSERT not an UPDATE.

Could it be that you have both entires in your DB and only viewing one
of them retrieved?

The code you show is incomplete so its hard to tell.

If you follow the code you have with:

while($user = mysql_fetch_arr ay($resource)) {
echo $user[username]."<br>";
}

Will it show the only one entry?

Also not sure if this is in your actual code or just typed it wrong in
here but:

$resource = mysql_query($qu ery) or die('Query failed: ' .

is missing the last )

Scotty

Sep 28 '08 #3
On Sep 28, 5:27*pm, FutureShock <futuresho...@a tt.netwrote:
Could it be that you have both entires in your DB and only viewing one
of them retrieved?
That was precisely it. Thanks!!

Jason
Sep 29 '08 #4
bodhiSoma wrote:
On Sep 28, 5:27 pm, FutureShock <futuresho...@a tt.netwrote:
>Could it be that you have both entires in your DB and only viewing one
of them retrieved?

That was precisely it. Thanks!!

Jason
Glad to help. Don't be a stranger.

Scotty
Sep 29 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1539
by: Jeff Nokes | last post by:
Hello, I'm using Cache::SharedMemoryCache with an Apache 1.3.28 / mod_perl 1.28 / Mason instance on RedHat Linux 7.2. The caching mechanism seems to work fine, it creates one shared memory segment and one semophore when in use. What I noticed was that when I gracefully shut apache down (completely), the segment and semaphore remain. I believe this is mostly intentional from design, but I would like to be able to remove any shared...
32
3228
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being lost when they move to a new record. This seems to be the case when there are multiple users. When there is a single user using it, we don't seem to have that problem. It seems that we had this problem when we first converted from an MDB back end...
1
2495
by: Chicken Kebab Abdullah | last post by:
I am making a database of my movie collection and I have a form which Shows a DVD Code in a combo, and a list of the divx movies on the dvd on the right in a list box. The combo boxes bound column is the dvdID but it is hidden just to show the name. Anyway, I use the normal access record navigation arrows to navigate through the dvd's I have and the combo box updates accordingly to a new dvd and as it does this I want it to requery my...
1
1621
by: John Rivers | last post by:
Hello, This topic has bugged me for years. The ideal for handling web forms would be that submitting the form replaces the browser history's current url with the url resulting from the form processing code Response.Redirect url
9
3563
by: Michael | last post by:
Hi, I have a large table. Normally, the user will need to see only the data from the past two years, but sometimes, they will need to go back further. I have a form with a datagrid, a DateTimePicker and a command button. What I'd like is when the user selects a new date and clicks the button, the grid would display data from the value in the datapicker through today. I have it working, but only if I select everything in the data...
3
5913
by: petermichaux | last post by:
Hi, I am trying to put together the last major pieces of my project's puzzle. This is more website/client-side architecture than JavaScript syntax but I hope this is a good place to ask. I'm a little stumped with which direction to take and advice would be greatly appreciated. I think this is a generally interesting problem but I haven't seen a post this long here before :S I have developed half of the admin interface for an e-commerce
2
2356
by: Ulrike Klusik | last post by:
Hello Folks, i've got two structural identical tables (including tablespace and indexes) with identical data, on which the access path of an SQL is differs. But I don't see a reason for the different behaviour. Both tables are allocated in the same database and storage space and use the same buffer pool. The DB2 subsystem is Version7.1 on z/OS. On both tables I've run REORG with standard statistics. I've checked for stale statistics...
2
3197
by: paula | last post by:
I have a front-end access database that uses a sql server back-end to link the tables. When I run the following code, the subform displays #deleted in place of the deleted record. What am I doing wrong??? s = "DELETE WMS_FID FROM WHERE =" & Me.txt_WMS_FID domcd.RunSQL (s) '*** PMP 9/22/07 - Copy the records to be deleted from t_PID to t_PID_Deleted table
1
2126
by: bkberg05 | last post by:
Hi -I have a form which contains a sub-form. The sub-form is tied to the main form by a shared field called Project_ID. The main form has one record per Project. The sub-form has many records per Project. When I'm adding Project records and go to a new record, the sub-form has no data in it. But then as soon as I type any data into the first field on the main form (after I type in the first character), the sub-form appears to populate...
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9376
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.