PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > Firefox oddities
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Firefox oddities

Réponse
 
LinkBack Outils de la discussion
Vieux 21/07/2007, 17h57   #1
Paul Duffy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Firefox oddities

Not sure what's going on here or even if it /is/ a PHP problem but...

Using PHP 5.1.6 on a remote server, accessing the page locally and I have
certain preconditions for setting , not setting , updating
, etc.

When accessed from Konqueror this all behaves as expected, when accessed
from Firefox however it all starts looking a bit weird.

The problem is that when the browser sends a value that isn't stored
in the database (and, so far, when $_SESSION has /a/ _id value),
while the desired result of a new db row and a reset and session
value are achieved, the variables I'm using to trace what's happening
report values as though the was always there.

Now, this _doesn't_ happen when I use Konqueror (I haven't yet tested
anything else) and everything happens as I expect it to. As it goes, if
you don't know how it's works when it's working, you won't know how to fix
it when it's broke so as much as it may all come to the same conclusion
I'd still like to know what's happening.

Output under FireFox with a new session after wiping the db clean is:

<!-- Initial ID = 118503664987 Initial Serv.ID = 118503664987 -->
<!-- ['ID'] 1 118503664987 -->
<!-- SESSION['ID'] 2 0 ['ID'] 3 0 -->
<!-- SESSION['ID'] 4 0 -->
<!-- SESSION['ID'] 5 118503664987 ['ID'] 6 118503664987 -->
<!-- Stored is 1 -->
<!-- SESSION['ID'] 7 0 -->
<!-- Time -->
<!-- Rand -->

Output under Konqueror (hoped for output) is:

<!-- Initial ID = 118488413231 Initial Serv.ID = -->
<!-- ['ID'] 1 118488413231 -->
<!-- SESSION['ID'] 2 0 ['ID'] 3 0 -->
<!-- SESSION['ID'] 4 118503675993 -->
<!-- SESSION['ID'] 5 0 ['ID'] 6 0 -->
<!-- Stored is 0 -->
<!-- SESSION['ID'] 7 0 -->
<!-- Time 1185036759 -->
<!-- Rand 93 -->

As can be seen below, output 4 should occur if !$_SESSION["ID"] and
if !$_Stored, 5 and 6 should only happen if the inverse is true.

CODE (not closed because this is a partial):

<?php

$one = 0;
$two = 0;
$three = 0;
$four = 0;
$five = 0;
$six = 0;
$seven = 0;

session_start();

if (!$dbHandle)
{
$connectDB = "host=***** hostaddr=***** dbname=*****
user=***** password=*****";

$dbHandle = pg_connect( $connectDB );
}

$uno = $_["ID"]; $duos = $_SESSION["ID"];

if (is_numeric($_["ID"]))
{ $s = pg_query( $dbHandle, "SELECT _id FROM WHERE
_id = ".$_["ID"].";");
$stored = pg_num_rows($s);

$one = $_["ID"]; }

if (!$_SESSION["ID"])
{
if ($stored)
{
$_SESSION["ID"] = $_["ID"];

$two = $_SESSION["ID"]; $three = $_["ID"];

$themeID = pg_query( $dbHandle, "SELECT theme_id FROM WHERE
_id = ".$_["ID"].";");
$_SESSION["themeID"] = pg_fetch_result($themeID, 0, 0);
set("ID", $_SESSION["ID"], time()+604800, '/',
'.odubtaig.net');
}
else
{
$Time = time(); $Rand = rand(0, 100); $_SESSION["ID"]
= $Time.$Rand; pg_query( $dbHandle, "INSERT INTO
(_id, theme_id) VALUES (".$_SESSION["ID"].", 1);");

$four = $_SESSION["ID"];

set("ID", $_SESSION["ID"], time()+604800, '/', '.odubtaig.net');
$_SESSION["themeID"] = "1";
}
}
else
{
if($stored)
{
if ($_SESSION["ID"] != $_["ID"])
{ $_SESSION["ID"] = $_["ID"]; }

$thisTheme = pg_query( $dbHandle, "SELECT theme_id FROM WHERE
_id = ".$_["ID"].";");
$_SESSION["themeID"] = pg_fetch_result($thisTheme, 0, 0);

$five = $_SESSION["ID"]; $six = $_["ID"];
}
else
{
$Time = time(); $Rand = rand(0, 100);
$_SESSION["ID"] = $Time.$Rand;
pg_query( $dbHandle, "INSERT INTO (_id, theme_id) VALUES
(".$_SESSION["ID"].", 1);");

$seven = $_SESSION["ID"];

set("ID", $_SESSION["ID"], time()+604800, '/',
'.odubtaig.net'); $_SESSION["themeID"] = "1";
}
}

$thisAddy = $_SERVER["HTTP_HOST"];

if ($_POST["theme"])
{
$_SESSION["themeID"] = $_POST["theme"];
pg_query( $dbHandle, "UPDATE SET theme_id =
".$_SESSION["themeID"]." WHERE _id = ".$_SESSION["ID"].";");
}


echo "<!-- Initial ID = ".$uno." Initial Serv.ID = ".$duos." -->
";
echo "<!-- ['ID'] 1 ".$one." -->
";
echo "<!-- SESSION['ID'] 2 ".$two." ['ID'] 3 ".$three." -->
";
echo "<!-- SESSION['ID'] 4 ".$four." -->
";
echo "<!-- SESSION['ID'] 5 ".$five." ['ID'] 6 ".$six." -->
";
echo "<!-- Stored is ".$stored." -->
";
echo "<!-- SESSION['ID'] 7 ".$seven." -->
";
echo "<!-- Time ".$Time." -->
";
echo "<!-- Rand ".$Rand." -->
";
  Réponse avec citation
Vieux 25/07/2007, 11h13   #2
C.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Firefox oddities

On 21 Jul, 17:57, Paul Duffy <odubt...@yahoo.dot.coh.dot.yoo.kay>
wrote:
> Not sure what's going on here or even if it /is/ a PHP problem but...
>
> Using PHP 5.1.6 on a remote server, accessing the page locally and I have
> certain preconditions for setting , not setting , updating
> , etc.
>
> When accessed from Konqueror this all behaves as expected, when accessed
> from Firefox however it all starts looking a bit weird.
>
> The problem is that when the browser sends a value that isn't stored
> in the database (and, so far, when $_SESSION has /a/ _id value),
> while the desired result of a new db row and a reset and session
> value are achieved, the variables I'm using to trace what's happening
> report values as though the was always there.
>
> Now, this _doesn't_ happen when I use Konqueror (I haven't yet tested
> anything else) and everything happens as I expect it to. As it goes, if
> you don't know how it's works when it's working, you won't know how to fix
> it when it's broke so as much as it may all come to the same conclusion
> I'd still like to know what's happening.
>


You're more likely to get a reply if you can reduce your code down to
something which demonstrates the problem *and* *nothing* *else*

I would suggest you look at the paths on the .

C.

  Réponse avec citation
Vieux 25/07/2007, 13h18   #3
Paul Duffy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Firefox oddities

>
> You're more likely to get a reply if you can reduce your code down to
> something which demonstrates the problem *and* *nothing* *else*
>
> I would suggest you look at the paths on the .
>
> C.


OK, I've tried to shorten it by stripping out the specifics of the code.

This is a test case for when a browser sends a bad ID. At a new
session outputs should only be for $uno, $one, $four, $Time and
$Rand (no session ID and not stored). Whether it's a new
session or not, Firefox gets $uno, $duos, $one, $five and $six (has session
ID and is stored) but not $four, $Time or $Rand.

Also, $stored comes back as 1 instead of 0 which should not happen
if the psql query was done before the ID was stored.

What's extra confusing is that, otherwise, it behaves as it should, a new
value is inserted into the database, the value held by FF changes
to this new value and all seems well. The only thing I can think of that
could be causing this would be FF calling the page again when a new
is set and reloading it in which case the values would be valid, but this
seems an unorthodox way for a browser to behave and could make debugging
an issue in future.

> CODE (not closed because this is a partial):
>
> <?php
>
> if (is_numeric($_["ID"]))
> { Check exists
> $stored = TRUE/FALSE(1/0);}
>
> if (!$_SESSION["ID"])
> {
> if ($stored)

set session ID
> else

set and session ID
> }
> else
> {
> if($stored)
> {
> if ($_SESSION["ID"] != $_["ID"])
> { $_SESSION["ID"] = $_["ID"]; }


> Set theme
> }
> else
> {

set new and reset session ID
> }
> }
>


> echo "<!-- Initial ID = ".$uno." Initial Serv.ID =
> ".$duos." -->
> ";
> echo "<!-- ['ID'] 1 ".$one." -->
> ";
> echo "<!-- SESSION['ID'] 2 ".$two." ['ID'] 3 ".$three." -->
> ";
> echo "<!-- SESSION['ID'] 4 ".$four." -->
> ";
> echo "<!-- SESSION['ID'] 5 ".$five." ['ID'] 6 ".$six." -->
> ";
> echo "<!-- Stored is ".$stored." -->
> ";
> echo "<!-- SESSION['ID'] 7 ".$seven." -->
> ";
> echo "<!-- Time ".$Time." -->
> ";
> echo "<!-- Rand ".$Rand." -->
> ";

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h06.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12286 seconds with 11 queries