html mail don't show

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
tomdude
Forum Newbie
Posts: 2
Joined: Thu May 19, 2005 6:11 pm

html mail don't show

Post 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);
?>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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);
tomdude
Forum Newbie
Posts: 2
Joined: Thu May 19, 2005 6:11 pm

Post by tomdude »

thank you Burrito. Will try that.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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
Post Reply