mark110384 Posted June 20, 2008 Share Posted June 20, 2008 A bit of a strange one, I've been developing some code for a shopping cart, it works fine in FireFox bit when I tried it in IE one of the pages didn't work, it is as though the PHP isn't even there or the HTML table that contains the PHP for that matter. Could anyone shed any light on this problem? Quote Link to comment Share on other sites More sharing options...
Jabop Posted June 20, 2008 Share Posted June 20, 2008 This has nothing to do with IE. Double check what you're doing. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 20, 2008 Share Posted June 20, 2008 well, that doesn't sound like a PHP issue, it sounds like a browser issue. If you post your code, we could tell you more reliably if the issue is browser or script. Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 20, 2008 Author Share Posted June 20, 2008 <? /*############################################################# - Script Name: addcart.php - - Description: Add a selected item to the table cart_items, - - check if it already exist and update and insert accordingly - #############################################################*/ session_start(); $session = session_id(); session_register($session); //Get values from itemdesc.php $qty = $_POST["qty"]; $itemname = $_POST["itemName"]; $price = $_POST["price"]; $itemid = $_POST["itemId"]; $createdate = date("Y-m-d G:i:s"); ?> <table width = "800" border = "0" cellpadding="0" cellspacing ="0" bgcolor="#0099CC" align="center"> <tr> <td><font face = "Arial" size ="4"><? echo $itemname; ?> was added to your shopping trolley.</font></td> </tr> </table> <? include("function.php"); //Get a connection to the database $connect = @ConnectToDb($dbhost, $dbuser, $dbname); //Update the session timestamp $updatesession = @UpdateSessionDate($newdate, $session); //Find itemId sent via viewitems.php addtotrolley button $sqlfinditem = "SELECT * FROM items WHERE itemId = '$itemid'"; $queryresult = mysql_query($sqlfinditem); while($myrow = mysql_fetch_array($queryresult)) { $itemname = $myrow['itemName']; $itemdesc = $myrow['itemDesc']; $price = $myrow['price']; $imagepath = $myrow['imagePath']; $alt = $myrow['alt']; //Set Quantity to = 1 if quantity string is empty otherwise preceed if (!$qty) { $quant = 1; } else { $quant = $qty; } //Search to see if the itemId already exist within cart_items $sqlselect = "SELECT * FROM cart_items WHERE itemId = '$itemid' and session = '$session'"; $result = mysql_query($sqlselect); $itemcount = mysql_num_rows($result); $itmid = ""; $itmid = $myrow['itemId']; //Count the number of rows found and less than or = to 0 insert in cart if ($itemcount <= 0) { //$qty =mysql_real_escape_string($qty); $sqlinsert= "INSERT INTO cart_items (itemId, price, quantity, session, createdate) values ('$itemid', '$price','$quant', '$session', '$createdate')"; if (mysql_query($sqlinsert)) { ?> <table width="671" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="339"></td> <td width="393"><table width="393" border="0" cellspacing="0" cellpadding="0"> <tr><td width="100"><? echo "<img src = '$imagepath' alt = '$alt' height = 200 width = 200 border = 0/>"; ?></td> <td width="217"><table width="227" border="0" cellspacing="0" cellpadding="0"> <tr> <td><? echo "<font face= Arial size = 2><b>£</b>" ."<b>$price /Each</b><br></font>";?></td> </tr> <tr> <td><? echo "<font face=Arial size = 2><b>$itemid $itemname</b></font>";?></td> </tr> <tr> <td height ="150"></td> </tr> </table></td> </tr> </table> <? } else { echo "Error! Failed to add item to cart."; } } else { $quantity =""; while($myrow = mysql_fetch_array($result)) { $quantity = $myrow['quantity']; } $totalqty = $quantity + $quant; // Else if itemid exists in cart_items update with new data mysql_query ("UPDATE cart_items SET quantity = '$totalqty' WHERE itemId = '$itemid' and session = '$session'"); ?> <table width="671" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="339"></td> <td width="393"><table width="393" border="0" cellspacing="0" cellpadding="0"> <tr><td width="100"><? echo "<img src = '$imagepath' alt = '$alt' height = 200 width = 200 border = 0/>"; ?></td> <td width="217"><table width="227" border="0" cellspacing="0" cellpadding="0"> <tr> <td><? echo "<font face= Arial size = 2><b>£</b>" ."<b>$price /Each</b><br></font>";?></td> </tr> <tr> <td><? echo "<font face=Arial size = 2><b>$itemid $itemname</b></font>";?></td> </tr> <tr> <td height ="150"></td> </tr> </table></td> </tr> </table> <? } //} ?> <html> <head> </head> <title>Lilley and Gillie - <? echo "$itemname successfully added to your shopping trolley";?></title> <body> <table width="350" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="60"></td> <td></td> </tr> <tr> <td height="38"><a href="viewitems.php"><img src = "continueshopping.bmp" border = "0"/></a></td> <td><a href="cart.php"><img src = "viewcartbutton.bmp" border = "0"/></a></td> </tr> </table> </body> <? } ?> </html> Quote Link to comment Share on other sites More sharing options...
lemmin Posted June 20, 2008 Share Posted June 20, 2008 If you view source on the page in IE does it give you anything? if so, can you post that? Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 23, 2008 Author Share Posted June 23, 2008 Yeah this is the source code from IE <table width = "800" border = "0" cellpadding="0" cellspacing ="0" bgcolor="#0099CC" align="center"> <tr> <td><font face = "Arial" size ="4"> was added to your shopping trolley.</font></td> </tr> </table> </body> </html> And the following in Firefox <table width = "800" border = "0" cellpadding="0" cellspacing ="0" bgcolor="#0099CC" align="center"> <tr> <td><font face = "Arial" size ="4"> was added to your shopping trolley.</font></td> </tr> </table> <table width="671" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="339"></td> <td width="393"><table width="393" border="0" cellspacing="0" cellpadding="0"> <tr><td width="100"><img src = 'F0750.JPG' alt = 'Set Square Image' height = 200 width = 200 border = 0/></td> <td width="217"><table width="227" border="0" cellspacing="0" cellpadding="0"> <tr> <td><font face= Arial size = 2><b>£</b><b>2.99 /Each</b><br></font></td> </tr> <tr> <td><font face=Arial size = 2><b>F0750 Set Square</b></font></td> </tr> <tr> <td height ="150"></td> </tr> </table></td> </tr> </table> <html> <head> </head> <title>Lilley and Gillie - Set Square successfully added to your shopping trolley</title> <body> <table width="350" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="60"></td> <td></td> </tr> <tr> <td height="38"><a href="viewitems.php"><img src = "continueshopping.bmp" border = "0"/></a></td> <td><a href="cart.php"><img src = "viewcartbutton.bmp" border = "0"/></a></td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 23, 2008 Author Share Posted June 23, 2008 The following is coding for the button passing the itemid over if its any help <? echo "<input type='image' src='addtotrolley.bmp' border='0' alt='Add' value = '$itemid' name = 'itemId'/>";?> Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 23, 2008 Author Share Posted June 23, 2008 I think that it is a problem that IE does not send the value from the button, has anyone else experineced this problem? Quote Link to comment Share on other sites More sharing options...
trq Posted June 23, 2008 Share Posted June 23, 2008 The following is coding for the button passing the itemid over if its any help <? echo "<input type='image' src='addtotrolley.bmp' border='0' alt='Add' value = '$itemid' name = 'itemId'/>";?> Thats isn't valid php. <?php echo "<input type='image' src='addtotrolley.bmp' border='0' alt='Add' value = '$itemid' name = 'itemId'/>"; ?> Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 23, 2008 Author Share Posted June 23, 2008 The following is coding for the button passing the itemid over if its any help Quote <? echo "<input type='image' src='addtotrolley.bmp' border='0' alt='Add' value = '$itemid' name = 'itemId'/>";?> Thats isn't valid php. <?php echo "<input type='image' src='addtotrolley.bmp' border='0' alt='Add' value = '$itemid' name = 'itemId'/>"; ?> ??? Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 23, 2008 Author Share Posted June 23, 2008 Found a soloution, I've put a hidden field containing the value that I want to pass Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 23, 2008 Author Share Posted June 23, 2008 Unfortunately that only adds the last item to the cart and not the one user selects, back to the drawing board Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 23, 2008 Author Share Posted June 23, 2008 I just changed the button to echo "<a href='addcart.php?item_selected=$itemid'><img src = 'addtotrolley.bmp' border = '0'/></a>" and it appears to work in both browsers with a couple of modifications to the addcart.php code Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.