adamzwakk
adamzwakk

Reputation: 709

MySQL query fails under IE6 only

I have a shop site where users can add/edit to a cart from a displayed list of products. Pretty simple stuff. On my "Add to Cart" button, (this is by client request) a confirm box pops up and asks if the user wants to add more to their cart. If they don't, it goes to the cart page to check out, if they do want to add more, it just refreshes the same page.

The problem I'm having is AFTER they click something in the confirm box and when that page refreshes, somehow the SELECT query to query the products to bring them up again (the exact query it just did) breaks... only in IE6.

The query itself looks something like this:

  $query_Recordset1 = sprintf("SELECT ProductID, Lang, MasterPack, ProductCategory, ProductSubCategory, Restricted1, ProductCode, ProductDesc, UnitsInStock, Image, Chargeable, UnitPrice, PDFName FROM tblInventory WHERE Client='Tenneco' AND InventoryGroup IN($invGroupStr) ORDER BY ProductCategory, ProductSubCategory, ProductDesc ASC LIMIT %s,50", GetSQLValueString($pg, "int")); 

It breaks at around $invGroupStr) AND ProductCategory='%s' at the bracket. I am certain that $invGroup is set to something.

Query after the sprintf is this:

SELECT ProductID, Lang, MasterPack, ProductCategory, ProductSubCategory, 
       Restricted1, ProductCode, ProductDesc, UnitsInStock, Image, 
       Chargeable, UnitPrice, PDFName 
FROM tblInventory 
WHERE 
    Client='Tenneco' AND InventoryGroup IN('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', '') 
ORDER BY ProductCategory, ProductSubCategory, ProductDesc ASC 
LIMIT 0,50

Is there something obvious that I should look into? This site was originally in PHP4 and is very poorly coded in general (I'm just tasked to take it over from what's already there).

Upvotes: 2

Views: 84

Answers (2)

adamzwakk
adamzwakk

Reputation: 709

Turned out it was a dumb error. When the "add to cart" does the ajax request, it does it under the NOT www. domain, which IE6 treats as a new user and deletes the current user's session. Which then makes that $invGroup invalid, hence the query fails. Not sure why someone would set it up that way.

One day I will redo this entire site with proper PHP5... one day.

Thanks @Jonathan Sampson for the help.

Upvotes: 0

Sampson
Sampson

Reputation: 268344

Queries don't run in the browser. It is impossible for IE to be the cause of a MySQL query failing since the query is run on your server, and not the client's browser.

Try printing out the errors associated with the broken query using mysql_error():

$result = mysql_query( $brokenQuery ) or die( mysql_error() );

Then work backwards from there.

Upvotes: 4

Related Questions