Avatar of Oneiroid
Oneiroid

asked on 

Firefox page source different than content in browser

I have coded my website in PHP with MySql for IE7, and am now testing it in Firefox 3.0.5.

One of my forms appears to be operating differently in Firefox, so I've echoed out all the variables involved to bug check. All of the variables are what I expect when I see them echoed on screen, but the resulting MySql statement executed at the same time [using the same variables] actually seems to be using different values in a couple cases.

At first I thought maybe Firefox was trying to execute the query twice, altering the values as it did, but I've been able to find no evidence of this.

I opened up the Page Source via Firefox, and low and behold, the values echoed in the debug statements were the same ones that my MySql statements were using, and were not the ones actually being displayed on the screen.

I've been wracking my brain over this one... I've not encountered a situation like this where the browser had anything to do with values being processed by the server. But I've tested the code between IE and Firefox extensively, and I can't figure out why I am getting the unexpected results from Firefox. Perhaps the incongruity between page source code and on screen content is a clue...

If I can provide any additional info, please ask! Thanks!
Web BrowsersPHP

Avatar of undefined
Last Comment
Ray Paseur
Avatar of MMDeveloper
MMDeveloper
Flag of United States of America image

can we see the HTML output of the page (using IE's view->source), firefox sometimes re-writes the HTML source to help it display the page better (if the HTML is badly malformed)
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Please post a link so we can compare the source you post here to the information we get when we visit.

FWIW, I have sometimes found that if you're using tabbed browsers and you have two tabs open to the same web page, you can find some oddities about the way sessions and cookies are handled.  If you think this could be involved, let us know.

Also, is there any browser-aware code running in the script?  It might be useful for us to see the PHP, as well.

Thanks and regards, ~Ray
Avatar of Oneiroid
Oneiroid

ASKER

I have uploaded the page source for both IE and FF:
http://65.36.238.78/other/IE_pagesource.txt
http://65.36.238.78/other/FF_pagesource.txt

... of course, if you view the FF source through a (any) browser, the debug values will display the same how they appear in the .txt file - which is not how they appear when the code is actually executed for this page.

Note the first line after the <body> tag (in the IE file):
direction: + 1<br>val1 = 1<br>val2 = 2<br>headline = 77<br>target = 98<br>

Just to be clear, this is also what I expected to see in the FF file because this same information was displayed on the screen. But you will see that the FF file actually contains different values for val1 (2) and val2 (3) - contrary to what was displayed through the browser.
Avatar of Oneiroid
Oneiroid

ASKER

Hi Ray,

I am not running any browser-aware code, and I've been very carful to only have one tab open in all the browsers I am using for testing pursposes.

Let me get back to you about the code. I am currently running it within a secure site so I'll have to pull it out for you to try. I will have to disable the MySql query as well (an update) so that you can test multiple time.

Thanks!
Avatar of Oneiroid
Oneiroid

ASKER

In creating a public test version for you to try, I've discovered that the problem seems to be coming from the UPDATE statement itself.

Here is the update statement tha causes the FF error:
mysql_query("UPDATE ticker SET rank = {$value2['rank']} WHERE ticker_ID = $headline_id");

If I comment this out, the debug values on the screen and in the source are the same (and are correct). And no update is made to the database.

If I replace the statement with another without variables, and instead replace the vaiables with the numbers that I expext those variables values would have been, I also get no error and the update works perfectly, like this:
mysql_query("UPDATE ticker SET rank = 2 WHERE ticker_ID = 77");

Of course this is no solution.

Two more observations:

1) Changing the query to: mysql_query("UPDATE ticker SET rank = 2 WHERE ticker_ID = $headline_id"); does the same as the original update (correct values show on screen but not in source and these wrong values are used in the update statement)

2) Changing the query to: mysql_query("UPDATE ticker SET rank = {$value2['rank']} WHERE ticker_ID = 77"); assigns the wrong variable to val1 and val2 in the source, BUT also displays these wrong values on the screen.

Anyway, attached is the code that executes (less the actual records listing that appears below it). I'm not sure now how I could meaningfully set up a public demo, since the update statement seems to be causing the problem...

// ID of record to move
$headline_id = $_GET['id']; 
		
// Get move direction up/down... -1/1
$direction = $_GET['reorder'] == "down" ? "+ 1" : "- 1";
 
// Get records values		
$target_ID = mysql_fetch_array(mysql_query("	SELECT ticker_ID from ticker where rank = ((	SELECT rank from ticker where ticker_ID = $headline_id   ) $direction )  "));
$value1 = mysql_fetch_array(mysql_query("	SELECT rank from ticker where ticker_ID = $headline_id"));
$value2 = mysql_fetch_array(mysql_query("	SELECT rank from ticker where ticker_ID = {$target_ID['ticker_ID']}"));
 
// Debug		
echo "direction: ".$direction."<br>";
echo "val1 = ".$value1['rank']."<br>";
echo "val2 = ".$value2['rank']."<br>"; 
echo "headline = ".$headline_id."<br>";
echo "target = ".$target_ID['ticker_ID']."<br>";
 
// Update		
mysql_query("UPDATE ticker SET rank = {$value2['rank']} WHERE ticker_ID = $headline_id"); // set new rank
 
// all other functional code to properly update the list was commented out for testing 

Open in new window

SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Oneiroid
Oneiroid

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Well, I would have only suspected the DB and NEVER a link statement, so, D'OH!

I'm glad you found it.  You might want to consider reporting it to Mozilla Foundation as a bug.

best regards, ~Ray
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Thanks for the points - this was a great question! ~Ray
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo