Page 1 of 2

Firefox vs Safari

Posted: Mon Mar 23, 2009 3:10 pm
by sleepydad
I'm authoring and testing on a Mac using MAMP as my server and Firefox and Safari as my browsers. The following is supposed to detect that an item has been zeroed out and if so remove it from the mySQLi database. It works perfectly in Firefox, but not Safari. Suggestions? ...

Code: Select all

 
$query="select * from shirtsII";
$result=$db->query($query);
 
$numRows=$result->num_rows;
 
for ($i=0; $i<$numRows; $i++) {
$row=$result->fetch_assoc();
if ($row['q1']==0 && $row['q2']==0 && $row['q3']==0 && $row['q4']==0 && $row['q5']==0) {
$query="delete from `shirtsII` where `index` = '".$row['index']."' limit 1";
$result=$db->query($query);
}
}
 
Thanks in advance -
sleepydad

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 3:42 pm
by php_east
you must have pasted the wrong set of codes in your drowsiness. these codes have nothing to do with safari or firefox.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 3:45 pm
by sleepydad
This is the php that I've written, and am testing in both Safari and Firefox browsers using MAMP as my testing server.

bright-eyed and bushy tailed dad

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 3:50 pm
by php_east
yeah, ok, but that php is not related to your browser in any way or am i mssing something :?:

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 4:04 pm
by sleepydad
My question is, "Why does the PHP script work (update the database) when tested in a Firefox browser on Mac but not in Safari browser on Mac?"

I'm sorry, I cannot be any clearer than that.

Thanks!

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 4:15 pm
by JAB Creations
Disable the cache feature in both browsers and it'll force it to get do an HTTP 200 instead of an HTTP 304. You can disable the cache in Firefox via the Web Developer Toolbar. In Safari you'll have to go in to edit menu, preferences, click on advanced, show the developer menu, then in the developer menu disable the cache.

Also you'll want to make sure you're watching your web server's access logs. Look at the HTTP code. If you're STILL getting the error and both browsers are giving code 200 instead of 304 (not modified) then you have something in your PHP that handles each browser differently.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 4:19 pm
by php_east
you question is clear, the point i am trying to get at is that those codes are executed by your PHP, and it must depend on something to trigger it to delete and from your codes it looks like it will be deleted when every columns (q1,q2 etc ) is zero.

the column value of zero is not determned by either safari or firefox, that is what i am saying and is all i can see, unless there is a form where these values are updated, after which this part of the codes comes into play.

so i suspect the problem lies with the form themselves rather than here, and that is where browser differences can sometimes play tricks.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 4:22 pm
by php_east
a fresh restart of the servers before each test/check is also recomended.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 4:26 pm
by sleepydad
Thanks guys. I'll give both of your suggestions a try.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 5:00 pm
by pickle
what ~php_east is getting at is PHP code is executed on the server, not on the client. The snippet you posted above is completely unrelated to the browser, because the browser never sees it, nor affects it.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 5:17 pm
by sleepydad
Exactly why I'm wondering the difference in behaviors between browsers. If the PHP is

"executed on the server, not on the client and is completely unrelated to the browser, because the browser never sees it, nor affects it"

why don't I get the same results regardless of the browser? I understand that it's all backend, but for some reason when I call the PHP page in Safari the variables are not sent to the database, but when I execute the exact same PHP page in Firefox they are - every time - no deviation. There has to be some browser intervention or interpretation/misinterpretation somewhere along the line. I've tested multiple times, stopped and restarted my servers, cleared my cache, closed and restarted my browsers even re-booted my machine and still the information that I enter into a Safari browser window is not posting to the database whereas in Firefox it works perfectly every time.

Not trying to be difficult, and I agree with the PHP executing on server but somehow/somewhere the browser (Safari) is running interference. The data entered into the interface when using Safari is not being posted to mySQL.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 5:24 pm
by Benjamin
Please post the code related to detecting the form data.

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 5:25 pm
by Mark Baker
sleepydad wrote:Not trying to be difficult, and I agree with the PHP executing on server but somehow/somewhere the browser (Safari) is running interference. The data entered into the interface when using Safari is not being posted to mySQL.
In that case, try looking at the HTML and any javascript of the page/form that actually does the submission to this script

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 5:46 pm
by sleepydad
This page, delegate.php, detects if the email address entered on previous page is already in database.

Code: Select all

 
$query="select * from `shirtsII`";
 
$result=$db->query($query);
 
$numRows=$result->num_rows;
 
for($i=0; $i<$numRows; $i++) {
$row=$result->fetch_assoc();
if ($email==$row['email']) {
$dupe=true;
$useIndex=$row['index'];
break;
}
}
 
if ($dupe) {
header("location: update.php?index={$useIndex}");
}
 
update.php reads:

Code: Select all

 
$index = $_GET['index'];
 
$query="select * from `shirtsII` where `index` = {$index}";
 
$result=$db->query($query);
 
$row=$result->fetch_assoc();
 
echo "<font size='+1' face='verdana'><b>Welcome back, ".$row['name'].".</b></font><br />"; 
echo "<font face='verdana'>Your current order is as follows:<br><br></font>";
 
echo "<form action='process.php' method='post'>";
 
echo "<table width='400' cellpadding='0' cellspacing='0' border='0'>";
echo"<tr><td colspan='3'><font face='verdana'>Name<br /></font></td></tr><tr>";
echo "<td colspan='3'><input type=''text' size='42' name='name' value='";
echo $row['name'];
echo "'>&nbsp;<br /></td></tr><tr>";
echo "<td colspan='3'><font face='verdana'>Email<br /></font></td></tr><tr>";
echo "<td colspan='3'><input name='email' type='text' size='42' value='";
echo $row['email'];
echo "' />&nbsp;<br /><br /><br /></td></tr><tr><td width='44'><font face='verdana'>Qty.</font><br />";
echo "<br /></td><td width='86'><font face='verdana'>Size</font><br /><br /></td><td width='170'><font face='verdana'>Style<br /></font>";
echo "<br /></td></tr>";
 
///////// MISC TABLE ROWS AND COLUMNS //////////
 
echo "<tr><td colspan='3'><br /><br /><input type='submit' value='Update' /></td></tr></table>";
echo "<input type='hidden' name='action' value='update'><input type='hidden' name='useIndex' value='".$index."></form>";
 
$result->free();
$db->close();
 

Re: Firefox vs Safari

Posted: Mon Mar 23, 2009 5:56 pm
by JAB Creations
Have you verified that the (X)HTML code on the page is valid?