Hi,
I have the Flash and PHP Bible and am trying to get the miniShoppingCart to work, but am unable to do so.
The files are available here: chapter 12
http://www.wiley.com/WileyCDA/WileyT...-DOWNLOAD.html
There is an error in the source code of the fla file line 27 reads:
but should be:Code:item.setStoreData(id, xmlItem.attribute('name'), xmlItem.attribute('desc'), xmlItem.attribute('thumbnail'));
I manually set up a database with a table named flashStore_products and put in a sample record filling in the name, description and price columns.Code:item.setStoreData(id, xmlItem.attribute('name'), xmlItem.attribute('desc'), xmlItem.attribute('thumbnail'),xmlItem.attribute('price'));
I am trying to run it off a server and do get an error of 'XML parser failure: element is malformed'. Im not sure if this is because its unable to process the php or not, but the productsLoaded function seems to be throwing that error. Here is the code for that function:
This is the relevant php code located in the flashCart.php file:Code:function productsLoaded(e:Event):void { var urlLoader:URLLoader = URLLoader(e.target); var xml:XML = new XML(urlLoader.data); trace("XML: " + xml); var id:uint = 0; for each(var xmlItem in xml..product) { var item:StoreItem = new StoreItem(); item.y = 85 * id; item.setStoreData(id, xmlItem.attribute('name'), xmlItem.attribute('desc'), xmlItem.attribute('thumbnail'),xmlItem.attribute('price')); item.addToCartBtn.addEventListener(MouseEvent.CLICK, addItemHandler); storeItems.addChild(item); id++; } addChild(storeItems); }
The checkout function within the same php file seems to work, but of course there are no products listed..Code:function getProducts() { global $link; $result = mysql_query("SELECT * FROM flashStore_products WHERE active=1", $link); $xml = "<products>\n"; while($row = mysql_fetch_array($result)) { $xml .= "<product id=\"" . $row['id'] . "\" name=\"" . $row['name'] . "\" desc=\"" . $row['description'] . "\" thumbnail=\"" . $row['thumbnail'] . "\" />\n"; } $xml .= "</products>"; return $xml; } if($_GET['action'] == 'getproducts') { print getProducts(); }
I realize that for someone to diagnose the problem they would probably need to download the source files, etc..but I'm stuck.
Any help would be greatly appreciated.
Thanks,
---Yvette




Reply With Quote