Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Sep 2009
    Location
    uk
    Posts
    83
    Thanks
    4
    Thanked 3 Times in 3 Posts

    help with sending an email to user

    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 .
    PHP Code:
    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 [user=$uid]Click here[/user]To 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

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Everything seems ok. Please show me result of print_r($mem); inserted in while-loop

  • #3
    New Coder
    Join Date
    Sep 2009
    Location
    uk
    Posts
    83
    Thanks
    4
    Thanked 3 Times in 3 Posts
    sorry am not clued up on these lil tricks hence the reason am asking for help .

    so were do i put that code ??

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Like what poyzn said, in the while loop. I'd put print_r($mem); echo '<br>'; so it prints nicely.

  • #5
    New Coder
    Join Date
    Sep 2009
    Location
    uk
    Posts
    83
    Thanks
    4
    Thanked 3 Times in 3 Posts
    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

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Ok, which of the following

    PHP Code:
    $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.

    PHP Code:
    $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.
    Last edited by Keleth; 11-09-2010 at 11:23 PM.

  • #7
    New Coder
    Join Date
    Sep 2009
    Location
    uk
    Posts
    83
    Thanks
    4
    Thanked 3 Times in 3 Posts
    PHP Code:
    $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,.

  • #8
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,536
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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:

    PHP Code:
    $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.

  • #9
    New Coder
    Join Date
    Sep 2009
    Location
    uk
    Posts
    83
    Thanks
    4
    Thanked 3 Times in 3 Posts
    fixed it . . thanks to you guys sort of pointing me in the right way . .
    Last edited by nclemale; 11-09-2010 at 11:52 PM. Reason: fixed it myself


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •