Page 1 of 1

html mail don't show

Posted: Thu May 19, 2005 6:18 pm
by tomdude
i'm having trouble with this email code.. it send the email but the variable $kari showed nothing. can anyone help me figure out please? thank a bunch.

Code: Select all

<?php
	$headers = &quote;From: &quote; . $_POST&#1111;'myID'];
	$headers .=  &quote;<&quote; . $_POST&#1111;'email'] . &quote;>\r\n&quote;;
	$headers .= &quote;Reply-To: &quote; . $_POST&#1111;'email'] . &quote;\r\n&quote;;
	$headers .= &quote;Content-type: text/html;\r\n charset=\&quote;iso-8859-1\&quote;\r\n&quote;;
	$z = $_POST&#1111;'myID'];
	
	include &quote;mysql.connect.php&quote;;
	mysql_select_db(&quote;test&quote;) or die(&quote;Could not select database&quote;.mysql_error());
	$query = &quote;SELECT DISTINCT custName FROM stock WHERE myID='$z'&quote;;
	$result = mysql_query($query) or die('Query failed: ' . mysql_error());
	$kari = mysql_result($result);
	$cant = 0;
	while($row=mysql_fetch_array($result)){
		echo &quote;reflect$cant=$row&#1111;reflect]&&quote;;
		$cant++;
	}
	
	// create message body
	$body = &quote;
	<html>
		<head>
			<title>test displaying stock</title>
		</head>
		<body>
		<p>Customer name</p>
		<table>
			<tr>
				<th>Name</th><th>&nbsp;</th>
			</tr>
			<tr>
				<td>$kari</td>
			</tr>
		</table>
		</body>
	</html>
	&quote;;
	
	//send the message
	mail(&quote;yeahman@nono.com&quote;,&quote;send results&quote;,$body,$headers);
?>

Posted: Thu May 19, 2005 6:30 pm
by Burrito
I think mysql_result() requires more than one argument???

Try it by adding a 0 for the second argument:

Code: Select all

$kari = mysql_result($result,0);

Posted: Fri May 20, 2005 9:54 am
by tomdude
thank you Burrito. Will try that.

Posted: Fri May 20, 2005 10:01 am
by phpScott
I also think this snippet might cause you some problems

Code: Select all

while($row=mysql_fetch_array($result)){
		echo "reflect$cant=$row[reflect]&";
		$cant++;
	}
needs a bit of a rethink.

Code: Select all

while($row=mysql_fetch_array($result)){
  $cant=$row[reflect];
}
then use $cant in your html email bit and don't worry about $kari