email php function repeat region not working
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: email php function repeat region not working
try using mysql_fetch_array() instead of mysql_fetch_assoc()
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
Code: Select all
<?php
$row_rsOrder = mysql_fetch_assoc($rsOrder);
var_dump($row_rsOrder);
while ($row_rsOrder = mysql_fetch_array($rsOrder)) { ?>
<tr valign='top'>
<td class='text'>".$row_rsOrder['ProductID']."</td>
<td class='text'>".$row_rsOrder['Product'].','.$row_rsOrder['catname']."</td>
<td colspan='2' class='text'>".$row_rsOrder['UnitSize']."</td>
<td><span class='text'>".$row_rsOrder['Quantity']."</span></td>
<td align='right' class='text'>". DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', '')."</td>
</tr>
<?php } ?>- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: email php function repeat region not working
Can you paste the results of var_dump($rows_rsOrder)
Code: Select all
<?php
$row_rsOrder = mysql_fetch_array($rsOrder);
var_dump($row_rsOrder);
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
below is what is showing in the table. there are actually three items for this orderCan you paste the results of var_dump($rows_rsOrder)
this information is set within a table
Product ID Category Product Description Size Quantity Price
488 Jersey Shorts Storm Grey Triangle 2 years 1 £ 27,00
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: email php function repeat region not working
now we know why only one set of values is being printedjonnyfortis wrote:Product ID Category Product Description Size Quantity Price
488 Jersey Shorts Storm Grey Triangle 2 years 1 £ 27,00
When displaying the results, do you also use mysql_fetch_assoc() ?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
this is what i use for displaying the results in the brower ( which works )now we know why only one set of values is being printed
When displaying the results, do you also use mysql_fetch_assoc() ?
Code: Select all
<?php do { ?>
<tr valign="top">
<td class="text"><?php echo $row_rsOrder['ProductID']; ?></td>
<td class="text"><?php echo $row_rsOrder['catname']; ?></td>
<td class="text"><?php echo $row_rsOrder['Product']; ?></td>
<td colspan="2" class="text"><?php echo $row_rsOrder['UnitSize']; ?></td>
<td><span class="text"><?php echo $row_rsOrder['Quantity']; ?></span></td>
<td align="right" class="text"><?php echo DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', ''); ?></td>
</tr>
<?php } while ($row_rsOrder = mysql_fetch_assoc($rsOrder)); ?> - social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: email php function repeat region not working
the code is in order so i'm not sure where the issue is; i can suggest an alternative that may or may not work. Since the display of the data is correct assign the variable with the data ($row_rsOrder) to another value and use that to create the data for the email.
If the var dump results of $orderData is the same as the values inside $row_rsOrder then you should be able to display the data in the email.
If the var dump results of $orderData is the same as the values inside $row_rsOrder then you should be able to display the data in the email.
Code: Select all
<?php
$rsOrder = mysql_query($query_rsOrder, $beau) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
// add this
$orderData = $row_rsOrder;
$totalRows_rsOrder = mysql_num_rows($rsOrder);
// where you display the results in the email
// $orderData should contain the same data as $row_rsOrder
var_dump($orderData);
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
so i dont add <?php do { ?> and replace with your code?the code is in order so i'm not sure where the issue is; i can suggest an alternative that may or may not work. Since the display of the data is correct assign the variable with the data ($row_rsOrder) to another value and use that to create the data for the email.
If the var dump results of $orderData is the same as the values inside $row_rsOrder then you should be able to display the data in the email.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: email php function repeat region not working
you'll still be using php code but now you will be using the array return by the innitial mysql_fetch_assoc() function;jonnyfortis wrote:so i dont add <?php do { ?> and replace with your code?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
i have done the belowyou'll still be using php code but now you will be using the array return by the innitial mysql_fetch_assoc() function;
Code: Select all
<?php
$rsOrder = mysql_query($query_rsOrder, $beau) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
// add this
$orderData = $row_rsOrder;
$totalRows_rsOrder = mysql_num_rows($rsOrder);
while ($row_rsOrder = mysql_fetch_array($rsOrder)) { ?>
<tr valign='top'>
<td class='text'>".$row_rsOrder['ProductID']."</td>
<td class='text'>".$row_rsOrder['Product'].','.$row_rsOrder['catname']."</td>
<td colspan='2' class='text'>".$row_rsOrder['UnitSize']."</td>
<td><span class='text'>".$row_rsOrder['Quantity']."</span></td>
<td align='right' class='text'>". DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', '')."</td>
</tr>
var_dump($orderData);
?>Code: Select all
Notice: Undefined variable: orderData in E:\Domains\b\website.com\user\htdocs\admin\order-details-sent.php on line 137Code: Select all
Notice: Undefined variable: orderData in E:\Domains\b\website.com\user\htdocs\admin\order-details-sent.php on line 153and in the actuall email that has still been sent the is the below in the Price column
£31,00var_dump();?>
Re: email php function repeat region not working
It should be:
Code: Select all
<?php
$rsOrder = mysql_query($query_rsOrder, $beau) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
// add this
$orderData = $row_rsOrder;
$totalRows_rsOrder = mysql_num_rows($rsOrder);
while ($row_rsOrder = mysql_fetch_array($rsOrder)) {
echo "
<tr valign='top'>
<td class='text'>".$row_rsOrder['ProductID']."</td>
<td class='text'>".$row_rsOrder['Product'].','.$row_rsOrder['catname']."</td>
<td colspan='2' class='text'>".$row_rsOrder['UnitSize']."</td>
<td><span class='text'>".$row_rsOrder['Quantity']."</span></td>
<td align='right' class='text'>". DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', '')."</td>
</tr>";
var_dump($row_rsOrder);
?>
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
should the " be after the echo?
echo "
echo "
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
I have tried without the " and got the following error in the page when the email function
Code: Select all
Notice: Undefined variable: orderData in E:\Domains\b\website.com\user\htdocs\admin\order-details-sent.php on line 137
array(69) { ["CustomerID"]=> string(3) "132" ["LastName"]=> string(5) "test" ["FirstName"]=> string(5) "test" ["Contact"]=> NULL ["Position"]=> NULL ["Address"]=> string(21) "32 test" ["Town"]=> string(7) "test" ["County"]=> string(6) "test" ["PostCode"]=> string(7) "test" ["Country"]=> string(14) "United Kingdom" ["Telephone"]=> NULL ["Fax"]=> NULL ["Email"]=> string(21) "test@hotmail.com" ["Password"]=> string(12) "test" ["CardNumber"]=> NULL ["CardType"]=> NULL ["CardExpMonth"]=> NULL ["CardExpYear"]=> NULL ["Timestamp"]=> NULL ["Level"]=> string(5) "Guest" ["LogTracking"]=> string(1) "0" ["UniqueID"]=> string(3) "164" ["OrderID"]=> string(3) "789" ["ProductID"]=> string(3) "494" ["StockID"]=> string(3) "105" ["Color"]=> NULL ["UnitSize"]=> string(14) "18 - 24 months" ["UnitPrice"]=> string(2) "32" ["Quantity"]=> string(1) "1" ["Discount"]=> NULL ["Total"]=> string(5) "55.95" ["EmployeeID"]=> string(1) "0" ["OrderDate"]=> string(10) "2013-04-16" ["RequestDate"]=> NULL ["ShippingDate"]=> NULL ["Courier"]=> NULL ["Shipping"]=> string(4) "4.95" ["Tax"]=> string(1) "0" ["BillingCustomer"]=> NULL ["BillingAddress"]=> NULL ["BillingTown"]=> NULL ["BillingCounty"]=> NULL ["BillingPostCode"]=> NULL ["TransactResult"]=> string(9) "Completed" ["TransactID"]=> string(17) "4AS36871JB354070D" ["MsgNum"]=> NULL ["ResponseMsg"]=> string(0) "" ["Fulfilled"]=> string(1) "1" ["Cancelled"]=> NULL ["Product"]=> string(20) "test 11223" ["Producer"]=> string(3) "OEM" ["Description"]=> string(233) "test " ["Colors"]=> NULL ["Price"]=> string(5) "32.00" ["MinimumQty"]=> string(1) "0" ["QtyDiscountLimit"]=> NULL ["Stock"]=> string(1) "1" ["UnitWeight"]=> NULL ["Image"]=> string(29) "item.jpg" ["ImageDetail"]=> string(29) "image.jpg" ["CatID"]=> string(1) "9" ["Clearance"]=> string(0) "" ["ID"]=> string(3) "494" ["SizeID"]=> string(1) "3" ["sold"]=> string(1) "0" ["Size"]=> string(11) "6-12 months" ["catID"]=> string(1) "9" ["catImage"]=> string(43) "image.jpg" ["catname"]=> string(7) "Jumpers" } "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $headers .= 'From: beauloves.co.uk ' . "\r\n"; $send = mail($to, $subject, $message, $headers); ?>-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: email php function repeat region not working
ok i changed the " for '
<?php
$rsOrder = mysql_query($query_rsOrder, $beau) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
// add this
$orderData = $row_rsOrder;
$totalRows_rsOrder = mysql_num_rows($rsOrder);
while ($row_rsOrder = mysql_fetch_array($rsOrder)) {
echo '
<tr valign='top'>
<td class='text'>".$row_rsOrder['ProductID']."</td>
<td class='text'>".$row_rsOrder['Product'].','.$row_rsOrder['catname']."</td>
<td colspan='2' class='text'>".$row_rsOrder['UnitSize']."</td>
<td><span class='text'>".$row_rsOrder['Quantity']."</span></td>
<td align='right' class='text'>". DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', '')."</td>
</tr>';
var_dump($row_rsOrder);
?>
and showed no errors but now i am getting
on line 137 the variable is
$orderData = $row_rsOrder;
which doesn't seem to be being used?
<?php
$rsOrder = mysql_query($query_rsOrder, $beau) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
// add this
$orderData = $row_rsOrder;
$totalRows_rsOrder = mysql_num_rows($rsOrder);
while ($row_rsOrder = mysql_fetch_array($rsOrder)) {
echo '
<tr valign='top'>
<td class='text'>".$row_rsOrder['ProductID']."</td>
<td class='text'>".$row_rsOrder['Product'].','.$row_rsOrder['catname']."</td>
<td colspan='2' class='text'>".$row_rsOrder['UnitSize']."</td>
<td><span class='text'>".$row_rsOrder['Quantity']."</span></td>
<td align='right' class='text'>". DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', '')."</td>
</tr>';
var_dump($row_rsOrder);
?>
and showed no errors but now i am getting
Code: Select all
Notice: Undefined variable: orderData in E:\Domains\b\beauloves.co.uk\user\htdocs\admin\order-details-sent.php on line 137$orderData = $row_rsOrder;
which doesn't seem to be being used?
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: email php function repeat region not working
the notice is caused because $orderData isn't defined before that line;
Code: Select all
<?php
$orderData = array(); // define $orderData, stop notice/s about the undefined variable
$rsOrder = mysql_query($query_rsOrder, $beau) or die(mysql_error());
$row_rsOrder = mysql_fetch_assoc($rsOrder);
// add this
$orderData = $row_rsOrder;
$totalRows_rsOrder = mysql_num_rows($rsOrder);
while ($row_rsOrder = mysql_fetch_array($rsOrder)) {
echo '
<tr valign='top'>
<td class='text'>".$row_rsOrder['ProductID']."</td>
<td class='text'>".$row_rsOrder['Product'].','.$row_rsOrder['catname']."</td>
<td colspan='2' class='text'>".$row_rsOrder['UnitSize']."</td>
<td><span class='text'>".$row_rsOrder['Quantity']."</span></td>
<td align='right' class='text'>". DoFormatCurrency($row_rsOrder['UnitPrice'], 2, ',', '.', '£ ', '')."</td>
</tr>';
var_dump($orderData); // <- we want to see what is inside this to determine whether it can be used or not
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering