Jump to content

Monkuar

Members
  • Posts

    987
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Monkuar

  1. $query = "LOWER(name)="$tabB"; on my forums, speakwhatsreal.com new message page, let's say somone on my site has the name "$tabB" how do i make the above query work so it selects a username with the $ symbol in it? because with that query it's linked to $DB->query("SELECT name, id, mgroup, language, email FROM ibf_members WHERE ".$query); $to_member = $DB->fetch_row(); if (empty($to_member['id'])) { $this->send_form(0, $ibforums->lang['err_no_such_member']); return; } pretty much says no results.. lol any help?
  2. hmm sounds mysql intensive do u recommend me just creating a button for a user to click to auto move the rank up/down each time? seems better and better performance? do u agree or no? MySQL won't even bat an eyelash at that. You could also just use multiple queries. In this case it won't hurt anything. could you help me run a foreach then? if i could do that with my query, even if somone selcted let's say 10 checkboxes, it will run 10 update queries, but it wont effect performance? if so that is great news, if you could help me
  3. hmm sounds mysql intensive do u recommend me just creating a button for a user to click to auto move the rank up/down each time? seems better and better performance? do u agree or no?
  4. My code: $rank = implode(',', $ibforums->input['rank']); echo $rank; For that form, it will show: '2,0,0' Problem is, I need to update each row with each individual value, and is this possible with using 1 query?
  5. NOW THAT"S WHAT IM TALKING ABOUT!!! WOW, Did not know you could freaking pass 2 array's in a value=XX this is great news LOL!!! man I bet I could even go up to 3-5 arrays eh? This is great news!! this code will be saved/etc so I can use in the future, thank you somuch, you just made my life 50% easier. :thumb-up: :thumb-up: :thumb-up:
  6. Yeah the array is not working though, if I use [1] like $id['1'] it only spits out the first character. I am using it inside the list function also. This is my current code: foreach($ibforums->input['checkbox'] as $postVal) { list($id, $friendid) = explode(',', $postVal); echo $id; } Exactly what you gave me, here are my checkboxes that a user will check (for instant) <input name="checkbox[]" onclick="check(this)" type="checkbox" id="checkbox[]" value="3,30"> <input name="checkbox[]" onclick="check(this)" type="checkbox" id="checkbox[]" value="1,2"> So we should be getting 3 and 1 right? I check those 2, and your code gives me: 31 which is right, it's getting 3 and 1, but i need it to be 3,1 which it is not displaying. Thank you,
  7. it's not returning them seperated in " , " tho? foreach($ibforums->input['checkbox'] as $postVal) { list($id, $friendid) = explode(',', $postVal); echo $friendid; } this will result in echoing " 302 " which is actually supposed to be 30,2 but i tried implode/explode the $friendid again and it's not working the $id and $friendid do work and show both arrays, thank you, now i just need to stick a , between em
  8. my whole table i tried $DB->query("UPDATE friends_pending SET pending='0', `date`='$time' WHERE id IN ($ids) AND toid IN ($ids2)"); not working and to reply to kicken i need to use the IN because i have mulitiple values, if i use ur method it will only update 1 row, or iwould have to use a query each time. It appears you ignored my suggestion to run a SELECT query. I suggested it because I suspected there were no records that matched the WHERE criteria, and according your output I was right; there are no matching records. hey, it's not your fault, the mysql developers don't support the "IN" clause being used with "AND", it wasn't gonna work, I just went ahead and used $DB->query("UPDATE friends_pending SET pending='0', `date`='$time' WHERE (id IN ($ids))"); $DB->query("UPDATE friends_pending SET pending='0', `date`='$time' WHERE (toid IN ($ids2))"); Another query aint gonna kill my db :shy: :shy:
  9. This is really cool if I can get it to work My PHP CODE: $ids = implode (",", $ibforums->input['checkbox']); Grabs from this data in my HTML FORM: <input name="checkbox[]" type="checkbox" value="{$r['id']},{$r['friendid']}"> Now when I pass my input, I will get 2 different values in both array's how do I separate them out? I know how to seperate them out using implode, but I need to seperate BOTH of the array's that are being passed, and I need to use them separately.
  10. So, your id's are 7,9. Based on your image of your data those rows both have a toid of 1. Are you trying to update those rows and their corresponding rows (8,10) so pending=0 on all? I don't think you'll be able to do what you want with two IN statements. You need to either get the other two row ID's (8,10) or match on both the to and from id's yea i guess u can't use AND with IN, what a bummer, mysql developers need to fix that.. so now i wil use $DB->query("UPDATE friends_pending SET pending='0', `date`='$time' WHERE (id IN ($ids))"); $DB->query("UPDATE friends_pending SET pending='0', `date`='$time' WHERE (toid IN ($ids2))"); works fine now but 1 more problem i will make a new topic
  11. nope i need to update both, if it was OR, it would prob just use only the id anyway, im doing this bcz if it the user accepts the friend request, it needs to update the other row to make it so they're friends, which if pending=0 = they are now friends..
  12. No no i passed all my arrays and implodes, it's the fact this query isn't using TOID to set the pending=0...there has to be away around this, just imagine switching the toid's with "ID" that's how I want it to work, it should set each pending=0 where toid=XX but it should work using the "IN" function which itis not :shrug: :shrug: :wtf: :wtf:
  13. I need to somehow change the info of the id 8 and 10 then this possible with the input I am receiving atm? this query should be working though i am using toid the same way as Id, just a different name, or that's how I think it's working, this query should work.... this is just making me mad atm all i need to do is.. IF toid=XXX change pending = 0.... but i want to run 1 query, if somone selects 20 users on the page and accepts them all as a friend, i am not running 20 queries on my page this stinks atm, im stuck
  14. UPDATE friends_pending SET pending='0', `date`='1324591002' WHERE id IN (7,9) AND toid IN (30,2) this is just amazingly making me stumped, query looks fine lol
  15. Not as a direct statement but defined as a function name. @monkuar Could you dump the query to see what you are actually executing? hmmiuno what you mean by dump, im not going to drop my table/etc just for some help XD This is what i need to do, set the pending = 0 to all the toid's and id's from the input array that i am grabbing. it works when i just use WHERE id IN ($ids) But if I add the AND toid IN ($ids2) It won't work, I am simply needing the toid values to be set to pending=0 along with my regular id values :shrug: :shrug:
  16. my whole table i tried $DB->query("UPDATE friends_pending SET pending='0', `date`='$time' WHERE id IN ($ids) AND toid IN ($ids2)"); not working and to reply to kicken i need to use the IN because i have mulitiple values, if i use ur method it will only update 1 row, or iwould have to use a query each time.
  17. $ids = implode (",", $ibforums->input['checkbox']); $time = time(); $ids2 = implode (",", $ibforums->input['pendingusers']); $DB->query("UPDATE friends_pending SET pending='0',date=$time WHERE id IN ($ids) AND toid IN ($ids2)"); weird thing is, it's not bring up any error's or nothing $ids2 spits out 2,30 and $ids spits out 9,7 for this particular project doesn't give me mysql error or nothing, script runs fine. I have mysql error enabling under $dbquery class so nn to worry, how to get this to work? :P Can i even use 2 IN's in 1 query or???
  18. So let's say if contact_name wants to add member_name as a friend, how would i make it say user is already pending? what variables to check? or should i make friends table and a friends_pending table?
  19. 1136622 is > than 864000, so it skips your code and goes down to the date() call with the format string. The problem here is that your number is not a timestamp, it's a duration so your formatted date is not going to be what you want. You need to either remove your limit on the duration, or rework your function to accept a timestamp value so that your date() call returns the correct result. Wow, could not believe I did not see that, Thank you "MasterACE14" for your reply also. this Code works fine for what I need, I am displaying a "time left" for a user who got suspended, so if it's: timeAgo2(19236622,5) it will show the user: 32 week 6 days 16 hours 30 min 22 seconds But one problem, I need to add months to this function, would I just simply add month into that array with the corresponding seconds?
  20. Ok I found the culprit and it's easy! function timeAgo2($timestamp, $granularity=3, $format='d:H:i:s'){ $difference = $timestamp; if($difference < 0) return '0 seconds ago'; elseif($difference < 864000){ $periods = array('week' => 604800,'day' => 86400,'hours' => 3600,'min' => 60,'seconds' => 1); $output = ''; foreach($periods as $key => $value){ if($difference >= $value){ $time = round($difference / $value); $difference %= $value; $output .= ($output ? ' ' : '').$time.' '; $output .= (($time > 1 && $key == 'day') ? $key.'s' : $key); $granularity--; } if($granularity == 0) break; } return ($output ? $output : '0 seconds').''; } else return date($format, $timestamp); } Now I will use: timeAgo2(136622,5) Which works and it will output: 2 days 14 hours 57 min 2 seconds But, if I add another "1" to it like this: timeAgo2(1136622,5) It shows: 14:03:43:42 Which is not right, it needs to show, 14 Days, 3hours 43minutes and 42 seconds.... Thank you, I finally explained myself better here, hope you understand
  21. Hey, that works, but when they refresh it will just keep showing "9seconds" instead of 8seconds, 7seconds,6seconds/etc. :confused:
  22. Sorry, for not explaining so much, let me try again When a user on my forum system get's a Warn, I want them to wait atleast 2weeks before they can click on my "request warn removal" Link. so I am pretty much just trying to add 2 weeks to the unixtimestamp, and echo it out as "14 Days Left" right after they get warned, then the next day, It will show "13 Days left"/etc, that's is what I am trying to get it show in my "$save['removal']" value, which is showing the above error, I posted. I used the 31570560 cuz that's how many seconds are in a year, thought I needed that on that array. I scratched that old code, see my post above :'(
  23. Ok, scratch that code, I was not explaining myself better. Here is the problem. I use: $save['removal'] = time() + (3600); Then when I try to echo my $save['removal'] out from my db, using this function: function timeAgo($tm,$rcs = 1) { $cur_tm = time(); $dif = $cur_tm-$tm; $pds = array('second','minute','hour','day','week','month','year','decade'); $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $no = floor($no); if($no <> 1) $pds[$v] .='s'; $x=sprintf("%d %s ",$no,$pds[$v]); if(($rcs > 0)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= $this->timeAgo($_tm, --$rcs); return $x; } I use this to echo it out: timeAgo($r['removal'],2); Now this is the problem.. it shows: instead of regular "XXX Minutes/seconds ago"
  24. if I do: $save['removal'] = time() + (3000); echo $save['removal']; exit; It is 1324314139 When I pull it from the db it is: "1355847038"
  25. function timeAgo2($timestamp, $granularity=3, $format='d:H:i:s'){ $difference = $timestamp; if($difference < 0) return '0 seconds ago'; elseif($difference < 31570560){ $periods = array('year' => 31570560, 'month' => 2630880, 'week' => 604800,'day' => 86400,'hours' => 3600,'min' => 60,'seconds' => 1); $output = ''; foreach($periods as $key => $value){ if($difference >= $value){ $time = round($difference / $value); $difference %= $value; $output .= ($output ? ' ' : '').$time.' '; $output .= (($time > 1 && $key == 'day') ? $key.'s' : $key); $granularity--; } if($granularity == 0) break; } return ($output ? $output : '').''; } else return date($format, $timestamp); } Okay, I have this: $save['removal'] = time() + (1209600); I am adding 2weeks + time() to my $save['removal'] variable. Then I will wrap my function timeAgo2 around my $save['removal'], and it shows: "19:15:50:20" but if I do $save['removal'] = time() + (300); Then it works, and shows "5minutes ago/etc" Why doesn't it work when I try to add 2weeks to my $save['removal'] variable? It seems it reads my $format if I try to set my time higher then 5minutes.... no idea...?
×
×
  • 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.