Firefox vs Safari

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Firefox vs Safari

Post 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
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Firefox vs Safari

Post 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.
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Firefox vs Safari

Post 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
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Firefox vs Safari

Post by php_east »

yeah, ok, but that php is not related to your browser in any way or am i mssing something :?:
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Firefox vs Safari

Post 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!
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Firefox vs Safari

Post 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.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Firefox vs Safari

Post 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.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Firefox vs Safari

Post by php_east »

a fresh restart of the servers before each test/check is also recomended.
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Firefox vs Safari

Post by sleepydad »

Thanks guys. I'll give both of your suggestions a try.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Firefox vs Safari

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Firefox vs Safari

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Firefox vs Safari

Post by Benjamin »

Please post the code related to detecting the form data.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Firefox vs Safari

Post 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
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Firefox vs Safari

Post 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();
 
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Firefox vs Safari

Post by JAB Creations »

Have you verified that the (X)HTML code on the page is valid?
Post Reply