Jump to content

Sideclef

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Posts posted by Sideclef

  1. Well I am completely new to php.

    I have this script  I have been working on for a few days now everything is working except the 2 update statements. I am sure that my script is pretty sloppy as well I apologize for that but as I have stated before I am quite new to this. Any ways the purpose of this script is to take money from one player and give to another. It is not based in sessions yes I know that's not good practice I am in the process of changing that now. Here's the script hope someone can be of some help. Thanks.


    $choice=strip_tags($_POST['choice']);

    if ($choice==2){

    //getting the random player

    $sql = mysql_query ("SELECT * FROM `users` ORDER BY RAND() LIMIT 0,1") or die (mysql_error ());

    $res = mysql_fetch_assoc ($sql);

    $randplayer = $res['username'];

    $geld =$res['geld'];

    //taking money from the random player

    $percent = rand(10,25);

    $takenGeld = round($geld * ($percent / 100));

    $picker =mysql_query("SELECT geld FROM users WHERE username=$cookieusername");

    $test=round($geld / $percent);

    $test1=$geld-$takenGled;

    $test2=$picker+$takenGeld;

     

     

    mysql_query("UPDATE `users` SET `geld`='$test1' WHERE `username`='$randplayer'");

     

    mysql_query("UPDATE `users` SET `geld`='$test2' WHERE `username`='$cookieusername'");

    }

     

     

     

    echo"You took $takenGeld from $randplayer

    This is a test  amout left $test1  and amout took $test2'";

     

     

     

     

    ?>

  2. I am looking for some help if anyone is available I am newly learning php and am looking for a friend that I could maybe come to when I have problems with things kinda like a mentor in a way. I wouldn't take up much of your time. I just need someone that can help point out my mistakes so that I don't keep making them. Someone to contact when I have no idea why this isn't working. Please contact me if you could help 

    why_id@yahoo.com

    Thanks Sideclef

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.