[FX.php List] calling a function not working
David Tinoco
davet15 at hotmail.com
Wed Oct 25 10:50:34 MDT 2006
Hi Guys,
I created 2 php files. One is called additem and contains a function called additem().
I am trying to call this function from another page.
Here is the additem page:
<?php
session_start();include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/FX.php");include_once($_SERVER['DOCUMENT_ROOT'] . "/FX/server_data.php");
function additem($item,$quantity){$finditem= '=='.$item;##If an order number already exists (an item has already been added.)if(isset($_SESSION['ordno'])){ ##Check to see if the item is already on the order.$checkitem=new FX($serverIP,$webCompanionPort);$checkitem->SetDBData('XXXXXX.fp7','Order Items');$checkitem->SetDBPassword($webPW,$webUN);$checkitem->AddDBParam('LinkOrder',$_SESSION['ordno']);$checkitem->AddDBParam('Item',$finditem);$checkitemResult=$checkitem->FMFind();foreach($checkitemResult['data']as $key=>$checkitemData);$checkitemCount = $checkitemResult['foundCount'];##If so, update the qty, do not create a new record.if ($checkitemCount > 0){$newamount = $checkitemData['OriginalQty'][0] + $quantity;$newitem=new FX($serverIP,$webCompanionPort);$newitem->SetDBData('XXXXXX.fp7','Order Items');$newitem->SetDBPassword($webPW,$webUN);$newitem->AddDBParam('OriginalQty',$newamount);$newitem->AddDBParam('-recid',$checkitemData['Line_ID'][0]);$newitemResult=$newitem->FMEdit();foreach($newitemResult['data']as $key=>$newitemData);$resultupc = $newitemData['Item'][0];}
##If there is no item in the cart, create the item.elseif ($checkitemCount == 0){$newitem=new FX($serverIP,$webCompanionPort);$newitem->SetDBData('XXXX.fp7','Order Items');$newitem->SetDBPassword($webPW,$webUN);$newitem->AddDBParam('LinkOrder',$_SESSION['ordno']);$newitem->AddDBParam('Item',$item);$newitem->AddDBParam('OriginalQty',$quantity);$newitemResult=$newitem->FMNew();foreach($newitemResult['data']as $key=>$newitemData);$resultupc = $newitemData['Item'][0];$_SESSION['item']=$newitemData['Item'][0];}}##If order number does not exist, safe to create a new order and add the item.else{$neworder=new FX($serverIP,$webCompanionPort);$neworder->SetDBData('XXXX.fp7','TempOrders');$neworder->SetDBPassword($webPW,$webUN);$neworderResult=$neworder->FMNew();foreach($neworderResult['data']as $key=>$neworderData);$_SESSION['ordno']=$neworderData['k_Session ID'][0];
$newitem=new FX($serverIP,$webCompanionPort);$newitem->SetDBData('XXXXXX.fp7','Order Items');$newitem->SetDBPassword($webPW,$webUN);$newitem->AddDBParam('LinkOrder',$neworderData['k_Session ID'][0]);$newitem->AddDBParam('Item',$item);$newitem->AddDBParam('OriginalQty',$quantity);$newitemResult=$newitem->FMNew();foreach($newitemResult['data']as $key=>$newitemData);$resultupc = $newitemData['Item'][0];$_SESSION['item']=$newitemData['Item'][0];}}
?>
________________________
>From a page that shows products in a catalog, the user click add to cart which takes them to the second page, viewcart.php from a form which has this in it:
<a href="viewcart.php?additem=1&item=10835&qty=3">Add to Cart</a>
Viewcart has this in it:
if(isset($_REQUEST['additem'])){$upc=$_REQUEST['item'];$amount=$_REQUEST['qty'];additem($upc,$amount);}
This viewcart has the include_once for the FX errors, FX.php and server_data page and include_once for the additem.php page. However, the error returned by PHP is that the FX variables do not exist ($serverIP, $webPW, etc.)
Notice: Undefined variable: serverIP in c:\Inetpub\wwwroot\viewcart.php on line 51Notice: Undefined variable: webCompanionPort in c:\Inetpub\wwwroot\viewcart.php on line 51Notice: Undefined variable: webPW in c:\Inetpub\wwwroot\viewcart.php on line 53Notice: Undefined variable: webUN in c:\Inetpub\wwwroot\viewcart.php on line 53Fatal error: Cannot use object of type FX_Error as array in c:\Inetpub\wwwroot\viewcart.php on line 55
Anyone know what I am doing wrong?
Thanks,
David
_________________________________________________________________
Check the weather nationwide with MSN Search: Try it now!
http://search.msn.com/results.aspx?q=weather&FORM=WLMTAG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20061025/37e07c2c/attachment.html
More information about the FX.php_List
mailing list