0

Hi all,

In the section of the order confirmation mail: $get_cart_info, when I include this theres is somehow a syntax error, as I keep getting this error after mail has tried to send:

Catchable fatal error: Object of class mysqli_result could not be converted to string in /home/www/ebm-fashion.dk/views/betaling_accepteret.php on line 129 (which is $get_cart_info query).

I am somehow stopping the email there. Isnt it possible to make a query inside this varaible when it is included in mail() function?

Its a pretty lame order confirmation if not even the products are in there, so I hope someone can point out what I am doing wrong!

THIS IS MY CODE:

$order_mail_comfirmation = '<div style="width:80%;">
    <p>Tak fordi du handlede hos ebm-fashion.dk.</p>
    <small>Der er registreret flg. detaljer vedrørende dit køb:</small><br /><br />
    <table>
        <tr>
            <td><small><b>Transaktions id:</b></small></td>
            <td style="padding-left:20px;"><small>'.$_SESSION['transaktions_id'].'</small></td>
        </tr>
        <tr>
            <td><small><b>Ordre id:</b></small></td>
            <td style="padding-left:20px;"><small>'.$_SESSION['order_id'].'</small></td>
        </tr>
        <tr>
            <td><small><b>Beløb hævet på kort:</b></small></td>
            <td style="padding-left:20px;"><small>'.number_format($samlet_pris,2).'</small></td>
        </tr>
        <tr>
            <td><small><b>Dato og tid:</b></small></td>
            <td style="padding-left:20px;"><small>'.$added_time.'</small></td>
        </tr>
    </table>
    <br />
    <small>
    Følgende vare(r) vil blive <b>afsendt</b> indenfor 1-2 hverdage, såfremt det ikke er en bestillingsvare.
    </small><br /><br />
<table>
'.$get_cart_info = mysqli_query($connection, "
SELECT produkt_id, navn, vare_type, model, antal, pris, str 
FROM cart_indloest WHERE user_id = '".$user_id."' AND ordre_id = '".$_SESSION['order_id']."'") or die(mysqli_error($connection));
while ($cit = mysqli_fetch_array($get_cart_info)) // $cit = cart items
    {
        // Hent billed extension fra produkter så billedet af det købte prdukt kan vises på kvitteringen:
        $get_img_info = mysqli_query($connection, "SELECT img FROM produkter WHERE id = '".$cit['produkt_id']."'");
        while ($img_ext = mysqli_fetch_array($get_img_info))
            {
                $img = $img_ext['img'];
            }

        '<tr>

          <td style="border:1px solid #666;">
              <img src="../backend/produkt_img/backend_img/'.$cit['produkt_id'].'.'.$img.'" width="60" height="90" />
          </td>

          <td style="padding-left:15px; padding-right:15px; background-color:#EEE; border:1px solid #666;">
              <small style="color:#333; font-weight:bold;"><b>• '.$cit['antal'].' par '
              .ucfirst($cit['navn']).' '
              .ucfirst($cit['vare_type']).' - Model '
              .ucfirst($cit['model']).' - Stk. pris: '
              .number_format($cit['pris'],2).' DKK. - Størrelse: '
              .$cit['str'].'</b></small>
          </td>
        </tr>';
    }
'</table>
<br />
<small>
EBM-Fashion forventer at varerne vil blive <b>leveret</b> indenfor 2-3 hverdage:
</small>
<br /><br />
<hr />
<br />
<small><b>Modtager og adresse er registreret til:</b></small>
<br />
<small> '.ucfirst($_SESSION['fornavn']).' '.ucfirst($_SESSION['efternavn']).' </small>
<br />
<small> '.ucfirst($_SESSION['gade']).' '.$_SESSION['hus_nr'].'<br />'.$_SESSION['post_nr'].' '.$_SESSION['by'].' </small>
<br /><br />
<small><b>Der er afsendt en kvittering til:</b></small><br />
<small> '. $_SESSION['email'].' </small><br /><br />
</div>';




// Send email til kunden her:
    $to         = $_SESSION['email'];
    $subject    = 'Ordrebekræftelse fra EBM-fashion';   
    $message    = $order_mail_comfirmation;

    $headers    = "Content-type: text/html; charset=utf-8rn";                   
    $headers    .= '<div style="width:500px; height:40px; padding-top:7px; background-color:#ccc; border:1px solid #666;">
    <p style="color:#666; margin-left:100px;">
    <b>Ordrebekræftelse</b>
    </p></div>';  
    $headers .= '<hr style="width:80%;" align="left"/>';     
    mail($to, $subject, $message, $headers);

Edited by Nick Evan: Code tags

2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by pritaeas
0

How come I cant include this file here inside my mail() message?
`<?php
$get_cart_info = mysqli_query($connection, "
SELECT produkt_id, navn, vare_type, model, antal, pris, str
FROM cart_indloest WHERE user_id = '".$user_id."' AND ordre_id = '".$_SESSION['order_id']."'");
while ($cit = mysqli_fetch_array($get_cart_info)) // $cit = cart items
{
// Hent billed extension fra produkter så billedet af det købte prdukt kan vises på kvitteringen:
$get_img_info = mysqli_query($connection, "SELECT img FROM produkter WHERE id = '".$cit['produkt_id']."'");
while ($img_ext = mysqli_fetch_array($get_img_info))
{
$img = $img_ext['img'];
}
echo
'<tr>

    <td style="border:1px solid #666;">
        <img src="../backend/produkt_img/backend_img/'.$cit['produkt_id'].'.'.$img.'" width="60" height="90" />
    </td>

    <td style="padding-left:15px; padding-right:15px; background-color:#EEE; border:1px solid #666;">
    <small style="color:#333; font-weight:bold;"><b>&bull; '.$cit['antal'].' par '
    .ucfirst($cit['navn']).' '
    .ucfirst($cit['vare_type']).' - Model '
    .ucfirst($cit['model']).' - Stk. pris: '
    .number_format($cit['pris'],2).' DKK. - Størrelse: '
    .$cit['str'].'</b></small>
    </td>
    </tr>';
}

?>`

This is the order confirmation I want to email to the customers, but I get this FATAL ERROR...
Catchable fatal error: Object of class mysqli_result could not be converted to string in /home/www/xxx/views/betaling_accepteret.php on line 128

This is the mail where I want to include however number of records contained in the variable $get_cart_info.
<?php $order_mail_comfirmation = ' Tak fordi du handlede hos ebm-fashion.dk.

Der er registreret flg. detaljer vedrørende dit køb:

Transaktions id: '.$_SESSION['transaktions_id'].' Ordre id: '.$_SESSION['order_id'].' Beløb hævet på kort: '.number_format($samlet_pris,2).' Dato og tid: '.$added_time.'
Følgende vare(r) vil blive afsendt indenfor 1-2 hverdage, såfremt det ikke er en bestillingsvare.

THIS IS WHERE I WANT TO OUTPUT $GET_CART_INFO; // BUT THE EMAIL DOESNT SEND IF I INCLUDE THIS VARIABLE, AND THROWS ME THE MENTIONED FATAL ERROR. I NEED TO DO A LOOP, AS THERE MIGHT BE MORE THAN ONE ROW TO RETRIEVE, AS THE CUSTOMERS COULD BUY MORE THAN ONE ITEM.
EBM-Fashion forventer at varerne vil blive leveret indenfor 2-3 hverdage:


Modtager og adresse er registreret til:
'.ucfirst($_SESSION['fornavn']).' '.ucfirst($_SESSION['efternavn']).'
'.ucfirst($_SESSION['gade']).' '.$_SESSION['hus_nr'].'
'.$_SESSION['post_nr'].' '.$_SESSION['by'].'

Der er afsendt en kvittering til:
'. $_SESSION['email'].'

'; // Send email til kunden her: $to = $_SESSION['email']; $subject = 'Ordrebekræftelse fra EBM-fashion'; $message = $order_mail_comfirmation; $headers = "Content-type: text/html; charset=utf-8\r\n"; $headers .= ' Ordrebekræftelse '; $headers .= ''; mail($to, $subject, $message, $headers); ?>

Anyone?

0

NEVERMIND, this editor completely fucks up what i write!

What happended to the old one..

Gotta find a new good forum, as this is driving me crazy.

Anyone knows a good one?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.