...

View Full Version : help with sending an email to user



nclemale
11-08-2010, 11:25 PM
hi . i need help with this small code i have made .
its basically the final page to a code that after users click a link that votes wether another user is hot or not . i have managed to get the message sent an inbox on the site but its adding the email sending am having trouble with .


else if($action=="hot")
{
$theme = mysql_fetch_array(mysql_query("SELECT theme FROM dave_users WHERE id='".$uid."'"));
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/$theme[0]\">";
$uid = getuid_sid($sid);
$who = $_GET["who"];
addonline(getuid_sid($sid),"Online list ","");

$hot = getnick_uid($uid);

$usl = "<br/><a href=\"index.php?action=viewuser\"></a>";
if(arebuds($uid, $who)==2)
{
$sub = "Hot Alert";
$msg = " You have been Voted Hot $hot Click hereTo view profile of $hot to say thanks ";
autopm($msg, $who, $sub);

$hot = mysql_fetch_array(mysql_query("SELECT hot FROM dave_users WHERE id='".$who."'"));
$res=mysql_query("UPDATE dave_users SET hot='".($hot[0]+1)."' WHERE id='".$who."'");
//////////////
$sql = mysql_fetch_array(mysql_query("SELECT id, name, addy FROM dave_users WHERE id='".$who."'"));
$ppl = mysql_query($sql);
while($mem = mysql_fetch_array($ppl))
{
$msg = "\n Username: ".$mem[1]." You have been voted hot on http://mysite.com. ";
$subj = "Voted hot ".$sitename."";
$headers = 'From: host@mysite.com' . "\r\n" .
'Reply-To: host@mysite.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($mem[2], $subj, $msg, $headers);
}
/////////////////////


echo "<img src=\"images/ok.gif\" alt=\"O\"/>User Voted Hot";
}else{
echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error Voting";
}
echo "</div>";
echo "<a href=\"index.php?action=main&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>Home</a>";
echo "</p>";
echo "<br/><br/><small>(c)>Nclemale</small>";
echo"</body>";
echo "</html>";
exit();
}


anyone fix this or point me in right direction. thanks

poyzn
11-09-2010, 04:26 AM
Everything seems ok. Please show me result of print_r($mem); inserted in while-loop

nclemale
11-09-2010, 10:49 PM
sorry am not clued up on these lil tricks hence the reason am asking for help .

so were do i put that code ??

Keleth
11-09-2010, 10:53 PM
Like what poyzn said, in the while loop. I'd put print_r($mem); echo '<br>'; so it prints nicely.

nclemale
11-09-2010, 11:15 PM
Warning: mysql_query() expects parameter 1 to be string, array given in /home/wapchat4/public_html/web/hotornot.php on line 197

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/wapchat4/public_html/web/hotornot.php on line 198
User Voted Hot
*Home
thats what i get as the error

Keleth
11-09-2010, 11:21 PM
Ok, which of the following


$hot = mysql_fetch_array(mysql_query("SELECT hot FROM dave_users WHERE id='".$who."'"));
$res=mysql_query("UPDATE dave_users SET hot='".($hot[0]+1)."' WHERE id='".$who."'");
$sql = mysql_fetch_array(mysql_query("SELECT id, name, addy FROM dave_users WHERE id='".$who."'"));

are lines 197 and 198? First, this is a TERRIBLE way to set things up. Break it up, so you can actually debug.


$hotQuery = "SELECT hot FROM dave_users WHERE id='".$who."'"
$hotResult = mysql_query($hotQuery);
$hot = mysql_fetch_array($hotResult);

$resQuery = "UPDATE dave_users SET hot='".($hot[0]+1)."' WHERE id='".$who."'";
$res=mysql_query($resQuery);

$userQuery = "SELECT id, name, addy FROM dave_users WHERE id='".$who."'";
$userResult = mysql_query($userQuery)
$sql = mysql_fetch_array($userResult);


With stuff broken up like that, you can actually debug. First thing, if you echo the queries on their own, what do you get?

Also, GIANT problem, you have no sanitizing.

nclemale
11-09-2010, 11:25 PM
$ppl = mysql_query($sql);
while($mem = mysql_fetch_array($ppl))

those are the 2 lines with the errors.


and yes i now i havnt secured it yet .its just a quick knock up at mo until i get the basics working,.

Keleth
11-09-2010, 11:28 PM
Its like its not even your code or you haven't read it...

mysql_query expects a string, a mysql query. Instead you feed it this:


$sql = mysql_fetch_array(mysql_query("SELECT id, name, addy FROM dave_users WHERE id='".$who."'"));

Which is an array, if that query is even working. So I'm not really sure what you're trying to do.

nclemale
11-09-2010, 11:42 PM
fixed it . . thanks to you guys sort of pointing me in the right way . .



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum