Re: whats wrong ?? functions&vars
| From: | David Robley | Date: | Mon, 13 Nov 2000 23:47:02 +0000 |
| Subject: | Re: whats wrong ?? functions&vars | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25059@lists.php.net to get a copy of this message | ||
On Tue, 14 Nov 2000, David Walgamotte wrote:
> I know its something that I'm doing wrong, the theory of operation is 2 add
> the data to a database and a flat file. The db add works the flat file add
> errors with "Undefined variable:". what's wrong ?
>
>
> function create_order(&$order) {
>
> global $SESSION;
>
> /* build the custinfo string */
> /* I need to pull this in the below function*/
> $custinfo =
> "Customer : $order->customer\n"
> . "Contact : $order->contact\n"
> . "Address : $order->address\n"
> . "Credit Card: " . chop_ccnum($order->creditcard) . "
> expiry $order->expiry\n";
>
> /* save order information first */
> $qid = db_query("
> INSERT INTO orders (
> username, o_timestamp, status, custinfo, comments, amount
> ) VALUES (
> '{$SESSION["user"]["username"]}'
> ,now()
> ,1
> ,'$custinfo'
> ,'$order->comments'
> ,'{$SESSION["cart"]->total}'
> )");
>
> $orderid = db_insert_id();
>
> /* now add the shopping cart items into the order_items table */
> $qid = get_cart_items();
> while ($item = db_fetch_object($qid)) {
> db_query("
> INSERT INTO order_items (
> order_id, product_id, price, qty
> ) VALUES (
> '$orderid'
> ,'$item->id'
> ,'$item->price'
>
> ,'{$SESSION["cart"]->items["$item->id"]}'
> )");
> }
>
> return $orderid;
> }
>
> " IN RED IS WHERE THE PROBLEM IS "
Now how am I supposed to see a colour in a text only mail package? But I'll
take a guess that the undefined variable is $orderid. And if db_insert_id is
some sort of function that returns the id of the last inserted record in a
MySql database, then it needs to be called after the record is inserted,
not before.
>
>
> function authorize_payment(&$orderid, &$status, &$status_details) {
>
> // $filewrite will write order data to a flat file
> $DATE = date("z");
> $filename ="/reports/$DATE";
> $fp = fopen( $filename,"a");
> fwrite( $fp, "------------------------ \n");
> fwrite( $fp," ORDER ID = " . "$orderid \n");
> fwrite( $fp," CUSTOMER = " . "$order->custinfo \n");
> fwrite( $fp," CONTACT = " . "$order->contact \n");
> fwrite( $fp," SHIPPING ADDRESS = " . "$order->address \n");
> fwrite( $fp," CREDIT CARD NUMBER = " . "$order->creditcard \n");
> fwrite( $fp, "------------------------ \n");
> fclose( $fp );
>
> $status = 1;
> $status_details = "Order completed successfully";
> return true;
> }
>
> thks dave
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA