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
tomdude
Forum Newbie
Posts: 2 Joined: Thu May 19, 2005 6:11 pm
Post
by tomdude » Thu May 19, 2005 6:18 pm
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 = "e;From: "e; . $_POSTї'myID'];
$headers .= "e;<"e; . $_POSTї'email'] . "e;>\r\n"e;;
$headers .= "e;Reply-To: "e; . $_POSTї'email'] . "e;\r\n"e;;
$headers .= "e;Content-type: text/html;\r\n charset=\"e;iso-8859-1\"e;\r\n"e;;
$z = $_POSTї'myID'];
include "e;mysql.connect.php"e;;
mysql_select_db("e;test"e;) or die("e;Could not select database"e;.mysql_error());
$query = "e;SELECT DISTINCT custName FROM stock WHERE myID='$z'"e;;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$kari = mysql_result($result);
$cant = 0;
while($row=mysql_fetch_array($result)){
echo "e;reflect$cant=$rowїreflect]&"e;;
$cant++;
}
// create message body
$body = "e;
<html>
<head>
<title>test displaying stock</title>
</head>
<body>
<p>Customer name</p>
<table>
<tr>
<th>Name</th><th> </th>
</tr>
<tr>
<td>$kari</td>
</tr>
</table>
</body>
</html>
"e;;
//send the message
mail("e;yeahman@nono.com"e;,"e;send results"e;,$body,$headers);
?>
Burrito
Spockulator
Posts: 4715 Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah
Post
by Burrito » Thu May 19, 2005 6:30 pm
I think mysql_result() requires more than one argument???
Try it by adding a 0 for the second argument:
tomdude
Forum Newbie
Posts: 2 Joined: Thu May 19, 2005 6:11 pm
Post
by tomdude » Fri May 20, 2005 9:54 am
thank you Burrito. Will try that.
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Fri May 20, 2005 10:01 am
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