Jump to content

ababmxking

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Posts posted by ababmxking

  1. $year = mysql_fetch_object(mysql_query("SELECT end YEAR FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $month = mysql_fetch_object(mysql_query("SELECT end MONTH FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $day = mysql_fetch_object(mysql_query("SELECT end DAY FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $hour = mysql_fetch_object(mysql_query("SELECT end HOUR FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $minute = mysql_fetch_object(mysql_query("SELECT end MINUTE FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $seconds = mysql_fetch_object(mysql_query("SELECT end SECOND FROM roundslog WHERE ended='No' AND end>'$date2'"));
    }
    // Define your target date here
    $targetYear  = $year;
    $targetMonth = $month;
    $targetDay   = $day;
    $targetHour  = $hour;
    $targetMinute= $minute;
    $targetSecond= $seconds;
    // End target date definition
    
    // Define date format
    $dateFormat = "Y-m-d H:i:s";
    
    $targetDate = mktime($targetHour,$targetMinute,$targetSecond,$targetMonth,$targetDay,$targetYear);
    $actualDate = time();
    
    $secondsDiff = $targetDate - $actualDate;
    
    $remainingDay     = floor($secondsDiff/60/60/24);
    $remainingHour    = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
    $remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
    $remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));
    
    $targetDateDisplay = date($dateFormat,$targetDate);
    $actualDateDisplay = date($dateFormat,$actualDate);
    
    ?>
    <link href="style/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
      var days = <?php echo $remainingDay; ?>  
      var hours = <?php echo $remainingHour; ?>  
      var minutes = <?php echo $remainingMinutes; ?>  
      var seconds = <?php echo $remainingSeconds; ?>  
    
    function setCountDown ()
    {
      seconds--;
      if (seconds < 0){
          minutes--;
          seconds = 59
      }
      if (minutes < 0){
          hours--;
          minutes = 59
      }
      if (hours < 0){
          days--;
          hours = 23
      }
      document.getElementById("remain").innerHTML = days+" days, "+hours+" hours, "+minutes+" minutes, "+seconds+" seconds";
      setTimeout ( "setCountDown()", 1000 );
    }
    
    </script>
    
    <?php echo "$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds";
    ?>
    

     

    i got this off of hotscripts.

     

    ok say the End date is 2008-07-07 18:37:23

    and the current date is 2008-07-02 23:53:27

    this is what the countdown writes. -2740 days, 2 hours, 7 minutes, 34 seconds

     

    this whole script confuses the hell out of me so im asking for some help.

  2. $year = mysql_fetch_object(mysql_query("SELECT YEAR end FROM roundslog WHERE ended='No' AND end>'$date2'"));
    
    $month = mysql_fetch_object(mysql_query("SELECT MONTH end FROM roundslog WHERE ended='No' AND end>'$date2'"));
    
    $day = mysql_fetch_object(mysql_query("SELECT DAY FROM end roundslog WHERE ended='No' AND end>'$date2'"));
    
    $hour = mysql_fetch_object(mysql_query("SELECT HOUR end FROM roundslog WHERE ended='No' AND end>'$date2'"));
    
    $minute = mysql_fetch_object(mysql_query("SELECT MINUTE end FROM roundslog WHERE ended='No' AND end>'$date2'"));
    
    $seconds = mysql_fetch_object(mysql_query("SELECT SECOND end FROM roundslog WHERE ended='No' AND end>'$date2'"));
    

     

    end is the datetime field in the table of the database, roundslog is the table ended is another table end is a datetime and $date2 = date('Y-m-d H:i:s');

     

     

    Ok im getting these errors with these querys.

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result

     

    would these be correct or what? i helped a guy with something like this last night and it had something like this in it.

  3. i found something for ya.

     

    SELECT * FROM table_name WHERE MONTH(date_column) = 4;

     

    not sure what (date_column) = 4; is but maybe someone can shed some light on it.

     

    edit

     

    might search google for something like "how to select month from a datetime" thats how i found that above.

  4. could add a spot in the database and have the posts update into a int the m number. so

     

    $month = date(m);

     

    if($db_month == '1'){

    echo" whatever";

    }

     

    something like that i spose would work but im sure theres an easier way to do it.

  5. Just tried it and when someone sends say 50bill it changes the amount to like 50 exactly. Im going to read the thing on php.net real quick though

     

    edit

     

    ok i just read through it, (im not that good with functions) but the way i read it, it adds a comma or decimal every 3 numbers, and since this is going into a database im guessing its cutting off everything after the first comma.

  6. im trying to remove any other characters that aren't numbers from a $_POST.

     

    $amount = intval($_POST['amount']);

     

    or something along them lines.

     

    sorry i guess it was intval that i was talking about not int.

    but it always rounds any number above 2,147,483,647 down to 2,147,483,647. I need something that will remove anything that isnt a number but not have a maximum amount.

  7. ya thats true. Theres a couple games like this and I guess I'm use to people knowing what to do. That will for sure be put in though. Theres a thing called missions, the new ones are going to show you how to play the game and what you need to do etc. But the ones up right now just have you do things that you probally dont know how to do.

     

    Anymore?

  8. Hello,

      a friend and I just recently learned how to code in PHP, roughly 4 months ago. We started making a game to practice PHP and have been working on it since, its grown nicely since then too. It still has like 14 or so things that we want to get done before we can call the game "Finished" but it is playable right now just not as many features as we want in it. The idea is to buy a car and race earn rep and race money and keep buying faster cars and maybe buy a unique(with real money) to speed the process up. The faster your the more money and rep you will gain. One of your goals should be to either win a Round or get to the top of one of the Blacklists. Anyways we are still learning coders and I'm sure there are some experienced coders that could find something wrong.

     

    The Site.

    Click Here

  9. One question. is there a certain type of language i need or something. because im thinking ive found the answer but just skipped over it on accident because i didnt reconize the language. I mean i know its not an exuse but ive only been coding for roughly 3 or 4 months so i havent come across allot of stuff ya know.

  10. I have a text based game where you can buy credits to get certain things in the game that are either only available for people that have bought credits or are cheats like Add xxxxxxx amount of money etc. But i cant think of a way to make it so if they successfully bought some credits it will add the credits to my database. I know of a way with something called greenlight but my game isn't making enough revenue for it to be worth while to pay like $10 usd to get an account with them.

     

  11. ya i have session_start() at the top of everypage.. but i just wrote that up real quick to help lessen the confusion on allot of other things i have in the code. but here is the actual code i am using right now. (with the isset updated on it)

     

    <?
    include 'other/require.php';
    include 'other/db_connect.php';
    include 'other/logincheck.php';
    $date = gmdate('Y,m,d m:i:s');
    $open = closed;
    
    if($open == 'open'){
    echo"
    <form action='moneytransfer.php' method='POST'>
    <center><table width='400' bgcolor='0a3a4d'><tr class='subject'><td colspan='2'><center>Money Transfer</center></td></tr>
    <div align=<'left'>
    <tr><td class='tdwhite2'><div align='right'><b> Amount : </B></div></td>
    <td class='tdwhite2'><div align='left'><input class='author3' type='text' name='tmon'></div></td></tr>
    <tr><td class='tdwhite2'><div align='right'><b> Username : </B></div></td>
    <td class='tdwhite2'><div align='left'><input class='author3' type='text' name='uname'></div></td></tr>
    <tr><td colspan='2'><center><input class='finduser' type='submit' name='submit' value='transfer'></center></form></td></tr>
    <table></center>";
    
    
    
    
    if ( isset($_POST['submit']) ) {
    $uname = strip_tags($_POST['uname']) ;
    $amount = strip_tags($_POST['tmon']) ;
    $cms = mysql_query("SELECT * FROM user WHERE username='$uname' LIMIT 1");
    $fms = mysql_num_rows($cms);
    $error = "no";
    $fls = mysql_fetch_object($cms);
    $fls2 = $fls->money;
    $result1 = $money - $amount;
    $result2 = $fls2 + $amount;
    mysql_query("INSERT INTO moneytransfer(sender,reciever,amount,date) VALUE ('$username', '$uname1', '$amount','$date')");
    $query22 = mysql_query("SELECT * FROM moneytransfer WHERE sender='$username' AND date='$date'");
    $fetch43 = mysql_fetch_object($query22);
    
    if ( $_POST['tmon'] > $money ) {
    echo"<center><font color='red'>You don't have enought money!";
    $error = "yes"; }
    
    if ( $_POST['tmon'] <= 0 ) {
    echo"<center><font color='red'>You cant send negative or 0 amounts!";
    $error = "yes"; }
    
    if ($username == $uname) {
    echo"<center><font color='red'>You can't send yourself money. 1";
    $error = "yes";}
    
    if($fetch43->sender == $fetch43->reciever){
    echo"<center><font color='red'>You can't send money to your self! 2";
    $error = "Yes";}
    
    if ( $fms == 0 ) {
      echo"<center><font color='red'>Username does not exist.";
    $error = "yes"; }
    
    if ($error == no  && $username != $fetch43->reciever){
    mysql_query("UPDATE user SET money='$result1' WHERE username='$username'");
    mysql_query("UPDATE user SET money='$result2' WHERE username='$uname'");
    echo "<center><font color='white'>Money transfered"; } }
    }
    else{
    
    echo"<font color=white><center>Money transfer is still being debugged.</font></center>";
    }
    ?>
    
    

  12. Ok so i have a text based game and we are having some problems with this.

    Heres the basic idea of the code

     

    <?
    
    if($_POST['submit']){
    $postedname = strip_tags($_POST['postedname']);
    $amount = strip_tags($_POST['amount']);
    $fetch = mysql_fetch_object(mysql_query("SELECT * FROM user WHERE username='$postedname'"));
    $fetchs = mysql_fetch_object(mysql_query("SELECT * FROM user WHERE username='$username'"));
    $moneyupdate = $fetch->money + $amount;
    $moneyupdate2 = $fetchs->money - $amount;
    
    $error = "No";
    
    if($username == $postedname){
    echo"<div align='center'>You can not send money to your self!</div>";
    $error = "Yes";
    }
    
    if($error == 'No'){
    echo"<div align='center'>You sent $postedname £".makecomma($amount).".";
    mysql_query("UPDATE users SET money='$moneyupdate' WHERE username='$username'");
    mysql_query("UPDATE users SET money='$moneyupdate2' WHERE username='$postedname'");
    
    echo"
    <form action='' mthod='POST'>
    <table>
    <tr>
    <td colspan='2' align='center'>Money Transfer</td></tr>
    <tr>
    <td align='right'>Username</td>
    <td align='center'><input type='text' name='postedname'></td>
    </tr>
    <tr>
    <td align='right'>Amount</td>
    <td align='center'><input type='text' name='amount'></td>
    </tr>
    <tr>
    <td align='center' colspan='2'><input type='submit' name='submit' value='Send Money'></td>
    </tr>
    

     

    Thats the basics of it. Of course theres stuff stopping it from sending negative amounts and to fake accounts. But they can type there username with a space at the end and send money to there self and there money will double. I tried fixing it with the strip_tags thing, i tried adding the usernames to a database when they are first submited and then checking if the usernames are the same in the database but it still doesnt work.

×
×
  • 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.