Jump to content

Gayner

Members
  • Posts

    549
  • Joined

  • Last visited

    Never

Posts posted by Gayner

  1. Because your localhost has error_reporting set to E_STRICT whereas your hosting is probably set to everything except notices. It's a very low level error, it means you are trying to access the item 'msg' in the $_GET array, but there isn't one. You should be doing...

     

    if(isset($_GET['msg'])) {
       // do something
    } else {
       // do something else
    }

     

    Wat the hell does isset do?

  2. you don't need to make a row in a mysql table to use sessions. Sessions have nothing to do with sessions really (as far as their mechanics go). I gave you an example in my first post, thats pretty much all you need to do.

     

    However, that's assuming you want them to only pray during a session (IE whenever they close the browser) or they can only pray once per prayer, or once a day/week/month etc. That would be different.

     

    I have a table that has thousands of rows full of prayers.

     

    and that code i showed u makes it so if somone clicks on "Pray for this Prayer" it says "Prayed" or whatnot i'll enhance that, the thing is that i only want that user to only beable to Prayer once for that individual prayer request but still pray for other thousand's of em u know?

     

  3. To do this I believe you would have to simple add another session that is the checker session.  If it is set and if you do a match search on the value to see if it has the usernames id then do let them even see it or something.

     

    How do I create another session? Or do i make a row in phpmyadmin that is the session name automatically?

     

    Sorry i am new on session

     

    BRB LOOKING INFO ON SESSIONS~

     

     

    OK back

     

     

    Bro, so i just make a row in phpmyadmin in my table called "prayer"

     

    then do if $_SESSION['pray'] = bla bal

     

    echo = " you alrdy Prayed for this Prayer sorry ! "

     

    This is kinda getting it u guys ?

     

    But the Prayer needs to be set for each prayer / row that that i have

  4. On my Prayer request site, i let users Click a button to Pray for somone that has posted a pray, i got that all set up but.

     

      // connect to db...
    
      if ($_GET['id']) {
        $id = (int) $_GET['id'];
        $sql = "update table set column=column+1 where id=$id";
        mysql_query($sql);
      }

     

    I want my users to beable to only Pray for a user once each, and then not beable to prayer for that user anymore, for each session

    how i do this? easy eh?

  5. My troll comment was directed towards emopoops.

     

    Gayner, I'll repeat, strtotime() returns a timestamp.

     

    ohlol

     

    I get it now, lol

     

    well my dam server is down ands i forgot to backup all my custom coded mini forum with everything..

     

    dood i need a new server bad,

    plz dont remove the code u posted here i need it :P thx

  6. Im just lost on what people are using -5days etc.

     

    i use the function around a unixtimestamp not any lettors or -5days or w/e... it's like 12343262 is the code and i wrap function around it, maybe somepeople are lost

     

    my server is down i'll try code when it get's up, then im leaving this server cause it's always down, i hope they can get backup cause i forgot to do a backup LOl

     

     

    I mean the orignally code i posted in my 1st thread works fine, i jsut asked for a adjustment so it's not just 5minues ago it's 5minutes 20second's ago or w/e not just 5minutes.. but i guess it turned into a glamorous fulfillment of generating ideas that came from hell LOL

  7. i do use the time function

     

    i insert it with time, thjen i need this function to replace everything so it converts to xx seconds/minutes ago, and it does work,

     

    but i just need it so IF it was 5minutes ago, then it will say:

     

    5minutes 20seconds ago, or w/e instead of just  5minutes ago..

     

    holy cow

  8. Neither of you read properly or understood what Gayner wishes to accomplish.

     

    I don't think it really makes sense to deal with years and months, as then you have to account for leap years and use slightly different logic.

     

    <?php
    
    echo time_elapsed( '2001-01-01 11:34 AM' ) . "\n";
    echo time_elapsed( mktime() ) . "\n";
    echo time_elapsed( strtotime( "-1 day" ) ) . "\n";
    echo time_elapsed( strtotime( "-2 hours -34 minutes" ) ) . "\n";
    
    function time_elapsed( $time ) {
        if( is_string( $time ) ) {
            $time = strtotime( $time );
            if( $time === false ) {
                throw new Exception( "Can not convert time string to timestamp." );
            }
        }
        
        if( is_numeric( $time ) === false ) {
            throw new Exception( "Can't make any sense of the time value." );
        }
        
        $curr_time = mktime();
        $time_diff = $curr_time - $time;
        if( $time_diff < 0 ) {
            return false;
        }
        if( $time_diff === 0 ) {
            return '0 seconds ago.';
        }
        
        static $divisors = null;
        if( $divisors === null ) {
            $divisors = array(
                array( 'day', 24 * 60 * 60 ),
                array( 'hour', 60 * 60 ),
                array( 'minute', 60 ),
                array( 'second', 1 )
            );
        }
        
        $descriptions = array();
        foreach( $divisors as $div ) {
            $val = time_elapsed_helper( $time_diff, $div[1], $div[0] );
            if( $val !== false ) {
                $descriptions[] = $val['description'];
                $time_diff = $val['remainder'];
                if( $time_diff === 0 ) {
                    break;
                }
            }
        }
        
        return count( $descriptions ) === 0 ? false : (implode( ' ', $descriptions ) . ' ago');
    }
    
    function time_elapsed_helper( $num_seconds, $divisor, $string ) {
        $rv = false;
        
        do {
            $result = (int)($num_seconds / $divisor);
            if( $result === 0 ) break;
            
            if( $result > 1 ) {
                $string .= 's';
            }
            
            $rv = array(
                'description' => $result . ' ' . $string,
                'remainder' => $num_seconds % $divisor
            );
        } while( false );
        return $rv;
    }
    ?>

     

    Roopurt, thanks but when i wrap time_elapsed('1258446691') around my variables it just shows up nothing,

     

    but it will do it if the date is like

     

    time_elapsed( '2001-01-01 11:34 AM' ) . "\n";

     

    or something

     

    hmm ?

  9. patronizing people trying to help you doesn't help your cause Gayner.  you need to read up on:

     

    http://us2.php.net/manual/en/function.mktime.php

    and

    http://us2.php.net/manual/en/function.date.php

     

    but to be more direct since you're offering no constructive feedback, take this for example:

     

    $ptime = "9/20/2009 10:20:59";
    
    $tempArray = explode(" ", $ptime); #break string up by the space char
    $dateArray = explode("/", $tempArray[0]); #break date fragment up by "/"
    $timeArray = explode(":", $tempArray[1]); #break time fragment by ":"
    
    #convert to unix timestamp
    $timestamp = mktime($timeArray[0], $timeArray[1], $timeArray[2], $dateArray[0], $dateArray[1], $dateArray[2]);
    
    #now u can convert to any date/time format you want since u have the unix timestamp
    echo date("d m y h:i:s", $timestamp);
    

     

    roflmao were not on the same line  here.

     

     

     

     

    Listen up :)

     

    I use time() into my row..

     

    then when i spit it out i will rap my function around the variable that spit's it out.

     

     

    So it would be

     

    time_elapsed_string("12353456")

     

    or whatever date it is then it will convert that and spit out:

     

    0seconds go

     

    or w/e

    5minutes ago or w/e

     

     

    Do u understand now?

     

    And this works jsut fine.

     

    I just want my script to be enhanced so it will say

     

    5Minutes 25seconds ago instead of just "5Minutes ago"

     

    Do u understand?

  10. dunno what $ptime stands for but what he said was, if you format $ptime using the php function called mktime(); then it will return a unix formatted time stamp, you can then use the php function named date(); to fromat this timestamp to display the data that you require.

     

    search into the functions on php.net.

    omg.. i know about unix stuff, i use this function around the unix timestamp to spit out "xxx minutes/seconds/ ago"

     

  11. Ok, take a step back and breathe. The reason I said 6 hours is because I basically mimiced the cookie your current script was setting. So doing this test everything is setup like the cookies are being set in your script. Going ahead 6 hours, which is the time you stated that you are logged out of your site automatically, will test if the issue is in your script, on your server or on your computer.

     

    Basically we are just trying to narrow down what the culprit maybe. Does that make sense? So adding 6 hours to your computer's time the cookie should still be valid, cause it is well under the 60 days like the cookie is set for. If it does get deleted then we can rule out your script and chances are it is something in your computer or on the server that is causing the issues. This is the act of testing and debugging.

     

     

    Werid cause i set my computer uplike 3days and refresh and im still logged in..

     

     

     

    but if i go to school and come back or gone for a period of long time it's always loggin me off..

     

    wth is going on

  12. you're making this WAY too difficult.  you need to take whatever format $ptime is coming in as, pass it to mktime() to get the unix timestamp and then u can use date() to format it however you want.. DAMN I LOVE PHP!

     

    My script is better then ur way why? cause i didn't understand 1 word u said

     

    This script works fine  i just need help on adding seconds onto "minutes ego" so it's

     

    5Minutes 25seconds ago instead of just 5 Minues ago

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