Re: Need your help again.. Sorry...
| From: | Justin French | Date: | Sun, 21 Jul 2002 02:38:13 +0000 |
| Subject: | Re: Need your help again.. Sorry... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108689@lists.php.net to get a copy of this message | ||
There's obviously something different that you're doing for the mail to the
fputs.
I don't why you'd run through the shopping cart items twice...
instead, I'd build the message in little fragments:
$msg ='';
$msg .= "Name: {$name}\n\n";
$msg .= "Email: {$email}\n\n";
...
this would include you adding e4ach item from the shopping cart.
then, when you send your mail:
mail($to, $subject, $msg, $headers);
then, use the SAME $msg to write to the backup file.
If you can get it right for the email, then the file write shouldn't cause
any problems.
justin
on 21/07/02 12:18 PM, Wee Keat (weekeat@amorphosium.com) wrote:
> Let me put it a little more detail here...
>
> I am trying to created an online ordering system where customers buy something
> and dump them in a cart and later, when they are happy, they will submit the
> order and 2 things will happen in one script:
>
> 1. The script before the line that I have submitted contain almost the same
> script but it is put in the mail() function. This mail() worked well... it
> generated the email, and the product list was created by retrieving from the
> database.
>
> 2. The second part of the script, which is the one I've shown you is the part
> where it fputs everything into a file (like a backup) just in case a customer
> calls up regarding an order and we didn't receive the email.
>
> So, 2 things are created and done simultaneously - an email generated and sent
> to me, and a log file created to store a copy of the order.
>
> Problem:
>
> The mail() script worked just fine, which shows that the $cart contained
> values. This is the result of the email:
>
> ------------------------------------------------------------------------------
> ------------------
>
> There is one Order on Oshima Website.
>
> Date: Sunday July 21, 2002
>
> Time: 12:14:42 pm
>
> From: John Doe
>
> Address:
> 1212 Flinders Street
> Melbourne VIC 3000
>
> Tel: 981781818
>
> Mobile:
>
> Fax: 819811818
>
> Email: john@doe.com
>
> Product Enquired:
>
> BTC BTC STANDARD PS/2 KEYBOARD $9.24
>
> BTC Multimedia Keyboard P/S2 (With Internet Functions) $15.40
>
> MICROSOFT Microsoft Wireless Value Pack - PS/2 (Single Unit-cond. app) $96.10
>
> ------------------------------------------------------------------------------
> ------------------
>
> And this is the result of the fput()
>
> ------------------------------------------------------------------------------
> ------------------
>
> Date: Sunday July 21, 2002
>
> Time: 12:14:42 pm
>
> From: John Doe
>
> Address:
> 1212 Flinders Street
> Melbourne VIC 3000
>
> Tel: 981781818
>
> Mobile:
>
> Fax: 819811818
>
> Email: john@doe.com
>
> Product Enquired:
>
> ------------------------------------------------------------------------------
> -----------------------
>
> Why?? Hmm... I was trying to figure this out for 2 days already...
>
> Thanks a lot for your reply.. Thanks so so much.
>
> :)
>
>
> Yours,
> Wee Keat Chin
>
> ---------------------------------------------------
>
> "Man is only truly great when he acts from his passions."
>
>
>
>
> ----- Original Message -----
> From: "John Holmes" <holmes072000@charter.net>
> To: "'Wee Keat'" <weekeat@amorphosium.com>; "'PHP
> General'"
> <php-general@lists.php.net>
> Sent: Sunday, July 21, 2002 11:39 AM
> Subject: RE: [PHP] Need your help again.. Sorry...
>
>
>> Are the other lines being written correctly? How does it "not work?"
>>
>> Are you sure there is anything in the $cart array?? If there isn't, the
>> while loop won't be executed. Put in a check to just make sure that it's
>> being executed.
>>
>> ---John Holmes...
>>
>>> -----Original Message-----
>>> From: Wee Keat [mailto:weekeat@amorphosium.com]
>>> Sent: Saturday, July 20, 2002 9:25 PM
>>> To: PHP General
>>> Subject: [PHP] Need your help again.. Sorry...
>>>
>>> Hi all...
>>>
>>> Sorry for troubling you guys again... but I really do not know what
>> else I
>>> could do.
>>>
>>> Can you please tell me why this code fputs($write, "$productlist");
>> isn't
>>> printing correctly?
>>>
>>> I have already connected to db. Just this particular one didn't
>> work...
>>> dun understand..
>>>
>>>
>>> The Code:
>>>
>>>
>>> fputs($write, "Email: $email\n\nProduct Enquired:");
>>>
>>> while (list($key,$prod_id) = each($cart)) {
>>>
>>> $cart[$key] = $prod_id;
>>>
>>> $result = mysql_query("SELECT * FROM products WHERE prod_id
>> =
>>> '$prod_id' ORDER BY prod_brand ASC", $link_id);
>>>
>>> $query_data = mysql_fetch_array($result);
>>>
>>> $gst = 1.10;
>>>
>>> $rrp = 1.12;
>>>
>>> $price = $query_data["price_lq"] * $rrp * $gst;
>>>
>>> $productlist .= "\n\n".$query_data["prod_brand"]."
>>> ".$query_data["prod_desc"]." $".number_format($price, 2,
>>> '.', '');
>>>
>>> fputs($write, "$productlist");
>>>
>>> }
>>>
>>> fputs($write, "\n\n-----------------------------");
>>>
>>>
>>>
>>> Please help... thanks soooo much again.
>>>
>>>
>>>
>>> Yours,
>>> Wee Keat Chin
>>>
>>> ---------------------------------------------------
>>>
>>> "Man is only truly great when he acts from his passions."
>