Jump to content

xwishmasterx

Members
  • Posts

    186
  • Joined

  • Last visited

Everything 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. ofcourse, that makes perfect sense...as I update db after retrieving the current values..thanks a bunch. PS. thanks for letting me know that "$PHP_SELF was depreciated and turned off by default 10 years ago", maybe I should start paying attention to post dates when using tutorials:)
  3. Hello I have a from that updates a few things in the db, and uses "<?php echo $PHP_SELF;?>". The form does update everything fine, however that page does not reflect it. If I refresh the page manually I can see the new values. Is this a common thing, and can anything be done to fix this?
  4. 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?
  5. Thanks for the reply, but found the error (very stupid one ) 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
  6. It does have a value, as I can see the correct value displayed for each row using echo. Since the $totalshares are calculated inside the while loop, why would it have a value outside of it?
  7. 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 ) ... 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.
  8. 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'])).""; .....
  9. 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.
  10. I think I am not making myself clear: I am NOT looking for the value of the new row. I am looking for a specific column value in the new row. eg. I insert: name, email to the table. the new row now has name, email, 24 , where 24 is the autoincrement value. How can I get the 24 value?
  11. Sorry for being sarcastic, but to my knowlegde these codes ussually do what you tell them too, not want you wish them to do What if I had two columns that did some autoincrement, how would you specify which of those values you need?
  12. 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?
  13. thanks for the reply. It only returns the value "0", it should return the newly created value for "invite_id" in the newly insterted row.
  14. 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:[email protected]"; 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
  15. that's a great thing, but I'm not really understanding where my timestamp should be added here..never really dealt with these functions before..
  16. 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?
  17. 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?
  18. Seems I was a little to quick here. I seems it puts out the result the way I want it, however the result is not correct, as it is not displying the right number..
  19. 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:)
  20. Thanks for your reply Andy, but not sure that is what I'm looking for. I am looking to show the specific member his place in the rankings, based on the count of the rows.
  21. 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?
  22. It didn't. I just need to do the same thing on another site using this other form:)
  23. 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
  24. Hello Sorry for the lousy title, but was unsure what too call this 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
  25. thanks for the answer. I am amazed that writing to a remote file is so difficult to setup.
×
×
  • 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.