Jump to content

xwishmasterx

Members
  • Posts

    186
  • Joined

  • Last visited

Posts posted by xwishmasterx

  1. Hello

     

    I am trying to do a cronjob to check if a user has been online within the past 24 hours.

    I have a column with "last_login" with this format: "1337593284".

     

    How can I do a simple if (last_login+24hours< servertime) {

     

    do something...

  2. Hello

     

    I am trying to do a simple button that will change a single field in database depending on its already existing value eg: if value is 0 then button should read 0 and on click change value in field to 1, and then button should read 1. Basically an "ON/OFF" button.

     

    Any examples to do this in a simple way?

  3. Thanks for the reply, but found the error (very stupid one :P)

    The update, updates ALL rows where profile_page_id=0, hence all rows are update with the last value. Added:

    ...WHERE profile_page_id=0 AND user_id= ".$row['user_id']."";...

    An it updates the value correct.

     

    Thanks for leading me in the right direction :)

     

  4. Hello

     

    Still pretty new to php, so I need a little help with the below code  (It's not pretty, but for now I just need it to work correct :P)

     

    ...
    while($row = mysql_fetch_array($result)){
    if($row['user_group_id'] <= 2){
    $multiplier = 1;
    }
    if($row['user_group_id'] == 6){
    $multiplier = 2;
    }
    if($row['user_group_id'] == 7){
    $multiplier = 3;
    }
    if($row['user_group_id'] == {
    $multiplier = 4;
    }
    $totalshares = ((($row['activity_blog']*$multiplier)/2)+(($row['activity_comment']*$multiplier)/10));
    
    $set_shares=mysql_query("UPDATE phpfox_user SET bod_shares=$totalshares WHERE profile_page_id=0");
    
    
    echo " User id: ".$row['user_id']." multiplier:".$multiplier." User group:".$row['user_group_id']." 
    - blog:".$row['activity_blog']." - comment:".$row['activity_comment']." totalshares= ".$totalshares."";
    echo "<br />";
    
    
    }
    ?>

     

    Problem is the UPDATE part "bod_shares=$totalshares", which just inserts "0".

    How do I get it to update the row with the correct value for each row?

    The echo shows the right values and calculation for $totalshares.

  5. Kevin, please understand that not everyone has English as their native language, and coding skills might not be very good.

    I am sorry for keep asking, but was trying to understand what was really happening when using the code.

     

    Also, a few of the example answers might have been correct use of the code, but not working in my case, which only confused me even more ;)

     

    I have gotten it too work, simple adding your suggestion in the right place ;)

     

    if($result = mysql_query($sql)) { 
    
    $inviteid = mysql_insert_id();
    
    $modtager = "".mysql_real_escape_string(stripslashes($_REQUEST['email'])).""; .....

  6. I have been looking around and tried google ;)

     

    Now, you say I need to use the function after my insert statement, but also I need to SELECT which row?

     

    I believe my poor explanation is why I keep asking ;)

     

    The problem in my original code is that the INSERT hasn't really taken place when I do my SELECT. (refreshing the page will get me a value, but not a solution)

     

    Was just wondering if you could query a table immediately after an insert looking for the newly created row, using a simple form, but might have to re-think it.

  7. That just confuses me.lol

     

    So after I do my insert, how do I specify what field I want to select?

     

    $sql = "INSERT INTO phpfox_invite (user_id,email,time_stamp,is_used) values ('".$b."','".mysql_real_escape_string(stripslashes($_REQUEST['email']))."','".$time."','1')";

     

    This will ofc create a new row, and the column "invite_id" with be generated with autoincrement. So how do I get that value?

  8. I have a small form, then after submit it inserts a new row with a few values (time, email)

     

    This form also sends email to the email from the form with a link.

     

    Problem, the link needs to contain an autoincrement value from the newly inserted row. How can I do this?

     

    (the form that obvioulsy doesn't work, for obviously reasons but to show what I try to accomplish:P)

     

    <? if (isset($_REQUEST['Submit'])) { 
    $time= time();
    # THIS CODE TELL MYSQL TO INSERT THE DATA FROM THE FORM INTO YOUR MYSQL TABLE 
    $sql = "INSERT INTO phpfox_invite (user_id,email,time_stamp,is_used) values ('".$b."','".mysql_real_escape_string(stripslashes($_REQUEST['email']))."','".$time."','1')";
    
    $sql = mysql_query("SELECT invite_id FROM phpfox_invite WHERE email='".mysql_real_escape_string(stripslashes($_REQUEST['email']))."'");
    $result = mysql_fetch_array( $sql );
    $inviteid = $result['invite_id'];
    
    if($result = mysql_query($sql)) { 
    $modtager = "".mysql_real_escape_string(stripslashes($_REQUEST['email']))."";
            $emne = "Please complete Your registration";
            $besked = "Click the link below to complete your registration: \n 
                                http://domain.com/invite/id_".$inviteid." ";
                               
            $header = "from:system@domain.com";
    
            mail($modtager, $emne, $besked, $header);
           echo 'Check Your Email!'; 
    } else { 
    echo "ERROR: ".mysql_error(); 
    } 
    
    ?>

     

    Everything works ok, but ofcourse I cannot get the 'invite_id' before the form is submitted and therefor cannot send the value ;)

     

  9. Hello

     

    I have a timestamp formated as : "2011-10-20 12:37:21"

     

    I need to show days left till this date (disregard the hours, minutes, seconds..), so I'll end up with 'there is "X" days left untill'

     

    I really cannot figure you all this date/time stuff, but hopefully this is not to difficult  :-\

     

    Anyone got a "quick" code for this?

     

     

  10. I got this code from a previous thread:

     

    mysql_query("SET @rows = 0;");
    $res = mysql_query("SELECT @rows:=@rows+1 AS view_rank,COUNT(id) AS views, credit_members_id FROM vtp_tracking GROUP BY credit_members_id ORDER BY views DESC");
    $n   = array(1 => 'st', 2 => 'nd', 3 => 'rd');
    while($row = mysql_fetch_row($res))
    {
       if ( $row[2] != $members_id )
          continue;
       if ( substr($row[0], -1) < 4 )
       {
          $row[0] .= $n[$row[0]];
       }
       else
       {
          $row[0] .= 'th';
       }
       echo ' You are in ' . $row[0] . ' place with ' . number_format($row[1]) . ' views.';
       break;
    }

     

    Everything seems ok except it orders by the "credit_members_id" and not "views" as entered.

     

    Can someone explain why, and how to fix this?

  11. I don't know if it's the right or wrong way to do it, but works exactly like I want it. Thanks a ton Andy!

     

    Btw, do PM me, as I am looking for a regular go-to guy with vairous things..including paid projects:)

  12. Hello

     

    I have a table that inserts a new row with data when a member views a page.

     

    I wish to count all the rows for each member, and then be able to show what the cuurent members "position" is eg. what members has the highest row count.

     

    Example. counting the rows for member_A returns 1000 rows, the number of rows for member_B returns 1500 rows.

     

    How can I display for member_A that he is in "second" place?

  13. Hello

     

    I am use to getting a members id fromthe URL using simple isset. The url looked like this ".....?r=membername". So getting the "r" value was easy.

     

    Now I have a url looking like this: ".....?membername". Is it still easy to get the membername? How should that be coded?

     

    Thanks

  14. Hello

     

    Sorry for the lousy title, but was unsure what too call this :shrug:

     

    I am currently writen a small coupon script, my problem is how I can check what member has already claimed a coupon.

    coupons are generated with simple inserting a new row with details ( name and other info ) to it's own table.

     

    I need help on how too setup that member xx has already claimed coupon xxxxxx? All ideas are welcome

     

     

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