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 7 of 7
  1. #1
    New Coder
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Payout #5 Firstlegend Not Updating

    This script is meant to reward the user who is firstlegend with goldcoins and news telling them they won. It is not updating at all, I dont think it is recognizing the users uid or email as its not giving them the goldcoins or the news, someone please help? I have been trying to figure this out all day

    PHP Code:
                    $nw2="SELECT firstlegend FROM game_settings";
                    
    $uid "SELECT uid, email FROM user_characters WHERE nickname ='".$nw2."'";
                    
    $sql "UPDATE users_goldcoins SET goldcoins=goldcoins+100 WHERE uid='".$uid['uid']."'";
            
    $sql mysql_query($sql) or die(mysql_error());
            
    $sql    "INSERT INTO `news` (`to` , `news` , `timestamp`) VALUES ('".$uid['email']."', '<br>Congratulations. You Have Won 100 B.D(s) For Finishing As First Legend Of The Round. ', '$time')";
            
    $sql mysql_query($sql) or die(mysql_error()); 

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You don't have any queries executing here, so things like $nw2 and $uid don't have any value aside from the query string.
    You can use selects and updates/inserts together.
    Code:
    UPDATE users_goldcoins ugc
    INNER JOIN user_characters uc ON uc.nickname = ugc.uid
    INNER JOIN game_settings gs ON gs.firstlegend = uc.nickname
    SET ugc.goldcoins = ugc.goldcoins + 100
    Code:
    INSERT INTO news (to, news, timestamp) VALUES
    SELECT uc.email, '<br>Congratulations. You Have Won 100 B.D(s) For Finishing As First Legend Of The Round. ', now()
    FROM user_characters uc
    INNER JOIN game_settings gs ON gs.firstlegend = uc.nickname
    Try those out in your dev environment and see if they work. If you can cut out 2 of the queries than you've used 50% less external calls which is a huge savings.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    VegasKiller (01-24-2014)

  • #3
    New Coder
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Thank you, I tried using them, prob the wrong way and this is still not resolved.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    What is the error you are receiving?
    Post your current code as well.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    New Coder
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    I am not receiving an error, It inserts the news row but is not putting in an email in the 'to'. I am also not receiving the goldcoins. This si the code I am currently running.

    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL);  

                     
    $time    time();
                     
    $nw2="SELECT firstlegend FROM game_settings";
                     
    $abc=mysql_query($nw2);
                     
    $cba=mysql_fetch_array($abc); 
                     
    $uid "SELECT uid, email FROM user_characters WHERE nickname =$cba";
                     
    $asd=mysql_query($uid);
                     
    $dsa=mysql_fetch_array($asd); 
                    
    $sql "UPDATE users_goldcoins SET goldcoins=goldcoins+100 WHERE uid='".$dsa['uid']."'";
            
    $sql mysql_query($sql) or die(mysql_error());
            
    $sql    "INSERT INTO `news` (`to` , `news` , `timestamp`) VALUES ('".$dsa['email']."', '<br>Congratulations. You Have Won 100 B.D(s) For Finishing As First Legend Of The Round. ', '$time')";
            
    $sql mysql_query($sql) or die(mysql_error()); 
    I am having the same issues for these scripts as well. This should be rewarding the top factions king pin. It recognizes the faction but is not recognizing the king pin so again, no reward is being given out.
    PHP Code:
             $sql="SELECT family, SUM(bank+cash) AS cnt FROM $prefix.user_characters WHERE family != '' and  family!='~Steam-Wars-Societeh~' GROUP BY family ORDER BY cnt DESC LIMIT 0,1;";
                     
    $sql=mysql_query($sql);
                      if(@
    mysql_num_rows($sql)==0) {}
                     else {
                     while(
    $temp=mysql_fetch_array($sql)) 
            {
                    
    $fam "King Pin";
                    
    $uid "SELECT uid, email FROM user_characters WHERE family ='".$temp[family]."' AND family_position='".$fam."'";
                    
    $sql "UPDATE users_goldcoins SET goldcoins=goldcoins+500 WHERE uid='".$uid."'";
            
    $sql mysql_query($sql) or die(mysql_error());
            
    $sql    "INSERT INTO `news` (`to` , `news` , `timestamp`) VALUES ('".$uid['email']."', '<br>Congratulations. You Have Won 500 B.D(s) For Finishing With The Top Faction. ', '$time')";
            
    $sql mysql_query($sql) or die(mysql_error());
                     }}



             
    $sql="SELECT familyname, drug_profit, creator FROM $prefix.families WHERE familyname != '' and  familyname!='~Steam-Wars-Societeh~' GROUP BY familyname ORDER BY drug_profit DESC LIMIT 0,1;";
                     
    $sql=mysql_query($sql);
                      if(@
    mysql_num_rows($sql)==0) {}
                     else {
                     while(
    $temp=mysql_fetch_array($sql)) 
            {
                    
    $uid "SELECT uid FROM user_characters WHERE nickname ='".$temp[creator]."'";
                    
    $sql "UPDATE users_goldcoins SET goldcoins=goldcoins+500 WHERE uid='".$uid."'";
            
    $sql mysql_query($sql) or die(mysql_error());
            
    $sql    "INSERT INTO `news` (`to` , `news` , `timestamp`) VALUES ('".$uid['email']."', '<br>Congratulations. You Have Won 500 B.D(s) For Finishing With The Top Faction Smuggling Points. ', '$time')";
            
    $sql mysql_query($sql) or die(mysql_error());
                     }} 
    And last, same problem for the newspaper company, it is recognizing the top rank newspaper but not its owner.
    PHP Code:
                     $sql="SELECT rank, owner, name FROM newspaper_company ORDER BY rank DESC LIMIT 0,1";
                     
    $sql=mysql_query($sql);
                     if(@
    mysql_num_rows($sql)==0) {}
                     else {
                     while(
    $temp=mysql_fetch_array($sql)) 
            {
                     
    $uid "SELECT uid, email FROM user_characters WHERE 'nickname' ='".$temp['owner']."'";
                     
    $ddd=mysql_query($uid);
                     
    $uidd=mysql_fetch_array($ddd); 
                     
    $sql "UPDATE users_goldcoins SET goldcoins=goldcoins+100 WHERE 'uid'='".$uidd['uid']."'";
             
    $sql mysql_query($sql) or die(mysql_error());
             
    $sql    "INSERT INTO `news` (`to` , `news` , `timestamp`) VALUES ('".$uidd['email']."', '<br>Congratulations. You Have Won 100 B.D(s) For Finishing With The Top Ranked Newspaper ".$temp['name'].". ', '$time')";
             
    $sql mysql_query($sql) or die(mysql_error());
                      }} 

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Things like this still won't work:
    PHP Code:
                     $uid "SELECT uid, email FROM user_characters WHERE nickname =$cba"
    $cba is an array, not a string. You can use it like this:
    PHP Code:
                     $uid "SELECT uid, email FROM user_characters WHERE nickname ='{$cba[firstlegend]}'"
    Did you try it with the joined queries? Don't forget that dbms can be configured for a maximum number of queries per hour, so you should limit the amount you have.

    Also, for insert/update/delete queries, you can use mysql_affected_rows() to find out the number of changes. If there is no error tossed from the query's mysql_error() and the affected rows are 0, it simply means you have no matching result based on the where clause.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    VegasKiller (01-27-2014)

  • #7
    New Coder
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Things like this still won't work:
    PHP Code:
                     $uid "SELECT uid, email FROM user_characters WHERE nickname =$cba"
    $cba is an array, not a string. You can use it like this:
    PHP Code:
                     $uid "SELECT uid, email FROM user_characters WHERE nickname ='{$cba[firstlegend]}'"
    Did you try it with the joined queries? Don't forget that dbms can be configured for a maximum number of queries per hour, so you should limit the amount you have.

    Also, for insert/update/delete queries, you can use mysql_affected_rows() to find out the number of changes. If there is no error tossed from the query's mysql_error() and the affected rows are 0, it simply means you have no matching result based on the where clause.
    Thank you, you are amazing


  •  

    Tags for this Thread

    Posting Permissions

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