Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help: How can I send mysql values via PHP mail?
Old 01-24-2009, 12:42 PM Help: How can I send mysql values via PHP mail?
Junior Talker

Posts: 3
Name: adan belo
Trades: 0
I try to insert the code below as html message to email any client but I always get this:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

I know i must covert " to ' but mysql is always having trouble

PHP Code:
$html_message ="<td height='12' bgcolor='#FFFFFF'><p align='center'>ITEM(s) ORDERED</p>
    <table width="229" border="0">
    <tr>
      <td width="10">&nbsp;</td>
      <td width="77"><div align="center">ITEM</div></td>
      <td width="59"><div align="center">QTY</div></td>
      <td width="65"><div align="center">PRICE</div></td>
    </tr>
    <?php
    
include('admin_config.php');
    
$visitid getenv('REMOTE_ADDR');
$query21  'SELECT * FROM cart WHERE visitid='$visitid'';
$result21 mysql_query($query21);
while(
$row mysql_fetch_assoc($result21))



$qty1 $row['qty'];
$code1 $row['code'];
    
    
?>
    
    <tr>
      <td></td>
      <td><div align="center"><?php echo $row['code']; ?></div></td>
      <td><div align="center"><?php echo $row['qty']; ?></div></td>
      <td><div align="center">$ <?php 
$query1  
'SELECT * FROM item WHERE code='$code1'';
$result1 mysql_query($query1);
while(
$row mysql_fetch_assoc($result1))
{    
$price $row['price'];
echo 
$price;
//$stocks = $row['$stocks'];
?></div></td>
    </tr><?php  
$sub 
$qty1 $price;
$total $total $sub;
    } 
?>
  </table>";

mail($receiver, $subject, $html_message,$header);

Last edited by chrishirst; 01-24-2009 at 01:46 PM..
pogsnet is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-24-2009, 12:48 PM Re: Help: How can I send mysql values via PHP mail?
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
You have not parsed the output, so your PHP injecting yourself. looking into the htmlentities() function ( http://uk2.php.net/manual/en/function.htmlentities.php ).

Also, does it say what line the error occurs?
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 01-24-2009, 12:58 PM Re: Help: How can I send mysql values via PHP mail?
PeachyJuice's Avatar
Super Talker

Posts: 116
Name: Michele T.
Location: Ny, Ny
Trades: 1
I don't see where you close $html_message so that's probably a problem as well. It does look like you have unescaped " inside that variable.

Also, you might want to do queries and such before starting to output to the string.
__________________
Freelance web+graphic designer and PHP developer.

Please login or register to view this content. Registration is FREE
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Old 01-24-2009, 02:00 PM Re: Help: How can I send mysql values via PHP mail?
Junior Talker

Posts: 3
Name: adan belo
Trades: 0
I forgot to mention that error appears in line

$qty1 = $row['qty']; <-- error message as stated on first post
pogsnet is offline
Reply With Quote
View Public Profile
 
Old 01-24-2009, 07:27 PM Re: Help: How can I send mysql values via PHP mail?
PeachyJuice's Avatar
Super Talker

Posts: 116
Name: Michele T.
Location: Ny, Ny
Trades: 1
You had some major syntax errors in a bunch of places. I fixed them for you but just so you know generally queries are done in " with ' used for variables like:
PHP Code:
$query "SELECT whatever FROM table WHERE item = '$thing'"
You also had some issues with closing your ?> then not opening it up again to actually do the mail function. It should be all cleaned up now =)

PHP Code:
<?php
$html_message 
='<td height="12" bgcolor="#FFFFFF"><p align="center">ITEM(s) ORDERED</p>
    <table width="229" border="0">
    <tr>
      <td width="10">&nbsp;</td>
      <td width="77"><div align="center">ITEM</div></td>
      <td width="59"><div align="center">QTY</div></td>
      <td width="65"><div align="center">PRICE</div></td>
    </tr>'
;
    include(
'admin_config.php');
    
$visitid getenv('REMOTE_ADDR');
$query21  "SELECT * FROM cart WHERE visitid='$visitid'";
$result21 mysql_query($query21);
while(
$row mysql_fetch_assoc($result21))



$qty1 $row['qty'];
$code1 $row['code'];
    
    
?>
    
    <tr>
      <td></td>
      <td><div align="center"><?php echo $row['code']; ?></div></td>
      <td><div align="center"><?php echo $row['qty']; ?></div></td>
      <td><div align="center">$ <?php 
$query1  
"SELECT * FROM item WHERE code='$code1'";
$result1 mysql_query($query1);
while(
$row mysql_fetch_assoc($result1))
{    
$price $row['price'];
echo 
$price;
//$stocks = $row['$stocks'];
?></div></td>
    </tr><?php  
$sub 
$qty1 $price;
$total $total $sub;
    } 
?>
  </table>";
<?php
mail
($receiver$subject$html_message,$header);php



?>
__________________
Freelance web+graphic designer and PHP developer.

Please login or register to view this content. Registration is FREE
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Old 01-24-2009, 09:23 PM Re: Help: How can I send mysql values via PHP mail?
Junior Talker

Posts: 3
Name: adan belo
Trades: 0
Thanks! I will have a try on this.... thanks alot for the help =)
pogsnet is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help: How can I send mysql values via PHP mail?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49404 seconds with 12 queries