String Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dbdvd7
Forum Newbie
Posts: 18
Joined: Fri Nov 17, 2006 2:33 pm

String Problem

Post by dbdvd7 »

Anyone know why this string doesn't work? Very green to php and have been messing with this for a day, anything will help.

Code: Select all

<?
error_reporting(E_ALL);
require("popupheader.inc");


$dbh=mysql_connect ("localhost", "", "");
mysql_select_db ("");

$result= mysql_query("SELECT * FROM CartItems")
or die(mysql_error());

$row = mysql_fetch_array($result); 

$order_string = <<< String

$row['product_name']
$row['Small']
$row['Medium']
$row['Large']
$row['XLarge']
String;
	

mail("ddunn@extramediumapparel.com","Order",$order_string);

    echo"<table border='0' cellspacing='10' cellpadding='10'>";

  echo"<tr><th>Thank You.  Your order has been processed and a confirmation e-mail will be sent to you.</tr></th>";


?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'll assume you're referring to your usage of heredoc.

I'd reason that you're attempting to use complex insertions.

The manual should be of use here. http://php.net/language.types.string
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Is there a reason that you need to use heredoc for this?

P.S. complex insertions are hot, rofl!
dbdvd7
Forum Newbie
Posts: 18
Joined: Fri Nov 17, 2006 2:33 pm

Post by dbdvd7 »

Im just trying to pull orders off mysql and have the respective sizes of each model emailed to me. I can get one model and sizes but not all of them. Is there an easier way?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

uhhhhhhhhh

if i remember correctly, rofl:

Code: Select all

$order_string = "
{$row['product_name']}\n
{$row['Small']}\n
{$row['Medium']}\n
{$row['Large']}\n
{$row['XLarge']}\n
";
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

ok so I would do it like so:

Code: Select all

$order_string = "$row['product_name'] $row['Small'] $row['Medium']  $row['Large']  $row['XLarge'] "; 
        

mail("ddunn@extramediumapparel.com","Order",$order_string);
Or something to that effect... format your $order_string how you want it.
edited....

Just saw what Daedalus put... LOL ya what he said.
Post Reply