Page 2 of 3

Re: email php function repeat region not working

Posted: Sun Apr 14, 2013 3:50 pm
by social_experiment
try using mysql_fetch_array() instead of mysql_fetch_assoc()

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 1:30 am
by jonnyfortis

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 }  ?>
is still only showing the 1st product

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 2:04 am
by social_experiment
Can you paste the results of var_dump($rows_rsOrder)

Code: Select all

<?php 
$row_rsOrder = mysql_fetch_array($rsOrder);
var_dump($row_rsOrder);
?>

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 3:35 am
by jonnyfortis
Can you paste the results of var_dump($rows_rsOrder)
below is what is showing in the table. there are actually three items for this order
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

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 4:07 am
by social_experiment
jonnyfortis wrote:Product ID Category Product Description Size Quantity Price
488 Jersey Shorts Storm Grey Triangle 2 years 1 £ 27,00
now we know why only one set of values is being printed

When displaying the results, do you also use mysql_fetch_assoc() ?

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 4:15 am
by jonnyfortis
now we know why only one set of values is being printed

When displaying the results, do you also use mysql_fetch_assoc() ?
this is what i use for displaying the results in the brower ( which works )

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)); ?> 

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 5:23 am
by social_experiment
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.

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);
?>

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 5:46 am
by jonnyfortis
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.
so i dont add <?php do { ?> and replace with your code?

Re: email php function repeat region not working

Posted: Mon Apr 15, 2013 4:57 pm
by social_experiment
jonnyfortis wrote:so i dont add <?php do { ?> and replace with your code?
you'll still be using php code but now you will be using the array return by the innitial mysql_fetch_assoc() function;

Re: email php function repeat region not working

Posted: Tue Apr 16, 2013 5:50 am
by jonnyfortis
you'll still be using php code but now you will be using the array return by the innitial mysql_fetch_assoc() function;
i have done the below

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);
?>
but get the following errors on the page.

Code: Select all

Notice: Undefined variable: orderData in E:\Domains\b\website.com\user\htdocs\admin\order-details-sent.php on line 137
this line:$orderData = $row_rsOrder;

Code: Select all

Notice: Undefined variable: orderData in E:\Domains\b\website.com\user\htdocs\admin\order-details-sent.php on line 153
this line: ";

and 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

Posted: Tue Apr 16, 2013 2:44 pm
by Jade
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);
?>

Re: email php function repeat region not working

Posted: Wed Apr 17, 2013 3:33 am
by jonnyfortis
should the " be after the echo?

echo "

Re: email php function repeat region not working

Posted: Wed Apr 17, 2013 3:44 am
by jonnyfortis
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); ?>

Re: email php function repeat region not working

Posted: Wed Apr 17, 2013 3:49 am
by jonnyfortis
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

Code: Select all

Notice: Undefined variable: orderData in E:\Domains\b\beauloves.co.uk\user\htdocs\admin\order-details-sent.php on line 137
on line 137 the variable is

$orderData = $row_rsOrder;

which doesn't seem to be being used?

Re: email php function repeat region not working

Posted: Wed Apr 17, 2013 4:44 am
by social_experiment
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
?>