
Monkuar
Members-
Posts
987 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Monkuar
-
if it's null it re-literates and counts it as a foreach, f my life, fixed it my self lol stupid me, thanks all
-
Okay, so my json data is: {"items":[null,{"id":"2","type":"m"},{"id":"1","type":"m"}]} $data = json_decode($_POST['itemid']); var_dump($data); foreach ($data as $name => $value) { foreach ($value as $entry) { $items[] = $entry->id; } } echo 'Here is a list of item id\'s sir!: <br><br> '.implode(",", $items).' </b>'; But for some odd reason it is showing: ,2,1 instead of just 2,1 is it because it's under 2 for eaches? I tried to remove the first foreach, but get stuck... anyone wanna help? Thanks in advance
-
{$indexed} please shoot me sorry
-
echo <<<L <a href='$indexedhelp.php?view=39'>hello</a> L; I need it to be like this: echo <<<L <a href='$indexedhelp.php?view=39'>hello</a> L; I want to use $indexed as a variable, but it actually joins with the word help, how do I fix? I want only indexed to be the variable, Thanks!!
-
WOW!! NO QUOTES!! LOL AND SUBSTRING_INDEX(last_post, '|', 1) >= 1 THANK YOU!! Marked as resolved! Love how the help document doesn't say anything about that, stupid site !
-
Hmm.. so how can I get the value of my last_post column to get SUBSTRINGED? So If it's finding the literal "last_post" that's not good, lol. I need it to explode through my last_post column I'm assuming. http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_substring this one seems like it would work but no delimiter? Also, I closed them with " quotes, still no results but no errors? So weird
-
Code: WHERE num_posts > 20 AND SUBSTRING_INDEX('last_post', '|', 1) > 1 IM trying to select my first explode in my last_post column. last_post value = 1342545240|614|11890|Find The Religion Forums So... I am trying to select where num_posts >20 AND last_post > 1343622791 The query shows no errors, but no results. Please help, Thanks "1343622791" will stand for whatever timestamp I want to be queried by. 1343622791 Is just an example.
-
I recently found this little script to help people making topics or posts with "WWWWWWWWWWWWWWWWWWWWWWWWWWWWW" OR "XX LETER HERE XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" Here it is: function FindInstances($inputString) { $enter = 0; $data = strtolower ($inputString); foreach (count_chars ($data, 1) as $i => $val) { if ($enter == 1) { $enter = 0; continue; } if (chr ($i) == "\n") { //echo "There are $val instance(s) of \" Enter \" in the string.\n"; $enter = 1; } else { //echo " There are $val instance(s) of \"" , chr ($i) , "\" in the string.\n"; $cletter =''.chr($i).''; if ($cletter == 'w' AND $val >= 5){ message("You cannot have 5 W's in your member title..."); }if ($cletter == 'o' AND $val >= 5){ message("You cannot have 5 o's in your member title..."); }if ($cletter == 'q' AND $val >= 5){ message("You cannot have 5 o's in your member title..."); }if ($cletter == 'm' AND $val >= 5){ message("You cannot have 5 o's in your member title..."); }if ($cletter == 'g' AND $val >= 5){ message("You cannot have 5 o's in your member title..."); }if ($cletter == 'c' AND $val >= 5){ message("You cannot have 5 o's in your member title..."); } } } } anyone know how to short this baby down so it works for all letters of the alphabet?
-
Thanks all, was just using the friends system as an example. I actually use xyph's method on my forum. I was just thinking, let's say a user want's to block people from viewing his topic. This user needs to click on a link to block such a user, such will indeed add that user's id to a column. Joe = 23 Nick = 52 Rascal = 29 Joe made a topic, wants to block nick and rascal from viewing, their id's are 52,29 respectfully. Joe blocks nick by adding the 52 to the "block" column. Now Joe want's to block rascal with the id of 29? I need to add 29 into the "block" column. That's easy, the problem is........... the block column now has "52,29" in it. Now Joe want's to remove Nick from the blocked column. (Wants to remove 52 id) how do I do that dynamically? Creating a whole other table for this, would be a scapegoat out of performance, their has to be a similar way by just using 1 column with a dynamical id array. Then again, this would be a bitch to check if that id was already inserted.... Would have to explode/foreach the column id's like a bitch too.. Hmmm maybe the whole table idea is the best way.
-
Okay, my brain is dumbfounded right now. Let's say I want to store these id's in a array in a row in my db. (Row name is "lol") lol current value = "5,2,1" now, let's say these are the id's of a user's friend list. The user wants to add a new friend, their user id is "23" How do I add "23" into the lol value "5,2,1" dynamically? I know one way is to select the lol column data and just add a ",$data" but that is not dynamic and what if the user want's to delete the user id "23" after they added that user as a friend? Thank you edit: 600th Post on the spot baby!
-
it was my fault, i apologize.. i was looking through the records in descending order and found like 10 7 6 5 4 1 so it does seem like I did delete some, (no idea why it was my fault)
-
Since I did delete 25 id's i'll just use $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); $stats['total_users'] = $db->result($result); $newstats= $stats['total_users']+25; topic solved, lol thanks all
-
i have 207 ROWS................... i count them, I have legimately 207 ROWS of id's but the cardinality is showing 187.............. there is something wrong here, how do I change the 187 to 207 to match how many id's I have in my table that's all I am asking
-
thanks for the code but something tells me that would hurt performance once my member's is in the thousands lol im just looking to fix it through mysql first then keep using $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); whenever thanks tho aha i just know it doesn't match with my 207 id's in my table so theres something wrong, and i am looking on a way to fix it through mysql i don't want to run 3 extra queries man
-
Most likely... somewhere down the road Is there any hope to restore the index primary a couple values? :'( :'( :'( :'(
-
Not be a noob but this is getting ridiculous and pissing me off.. I have this as my indexes PRIMARY BTREE Yes No id 182 A users_username_idx BTREE Yes No username (25) 182 A users_registered_idx BTREE No No registered 182 A Cardinality for my PRIMARY (ID IS STUCK AT 182) but my TABLE HAS 207 RECORDS, I need to update the 182 to 207 how? Why? because whenever I run this query $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); $stats['total_users'] = $db->result($result); It sucks and shows me 182, not the real "207" id's in my users table, this is really pissing me off. Hell I even deleted it and re made one, still shows 182? Damn I am lost
-
Long story short, this is part of myblack jack game when dealing cards $rand1 = rand(1, 11); $rand2 = rand(1, 10); Max of 21, okay so.... I need a function or something to exclude that number. Let's say user got 5 from $rand2. Now I need to make the $rand2 have a smaller percentage chance to spit out a 5 again. (I can use that a global variable, everything is in a database and serverside) Okay now a user get's 5 again from $rand2, I need to decrease the likelyhood of drawing a 5 again. Okay now the user hit's all 5 4 CARDS, now I need to make $rand2 variable exclude the number 5 because the guy already had 4 cards of 5, possible?
-
Here is my query: $db->query("SELECT cache.*,u.username from search_cache cache LEFT Join users as u ON u.id = 'NEED HELP HERE' where ident = '{$username}' ORDER BY DATE DESC") or error('Unable to send the message.', __FILE__, __LINE__, $db->error()); Here is my data inside my search_cache Here is my while loop: while($recent = $db->fetch_assoc($rec)){ $data = unserialize($recent['search_data']); } Now I can use $data['search_type'] as a array and If I use echo $data['search_type']['2'] it echo's out the user_id 32 as seen in the screenshot at the very end. Problem is, I want to use that 'NEED HELP HERE' to join with that id 32 dynamically, how the hell is that possible with mysql or is it? Or would it be easier to just add a new row/column named user_id and just join of that instead of trying to do all this? would that be faster?
-
Okay, Topic Solved, This was awesome, I actually learned some regex here
-
OKay, problem $input = '1,2,3,4,5,6,2'; if (!preg_match('/^\d+(,{1}\d)*$/', $input)) { echo 'invalid input'; } Works, but let's say a number that is 2integers long or higher? $input = '1,2,3,4,5,6,2521,231'; if (!preg_match('/^\d+(,{1}\d)*$/', $input)) { echo 'invalid input'; } I changed if (!preg_match('/^\d+(,{1}\d)*$/', $input)) { to if (!preg_match('/^\d+(,{4}\d)*$/', $input)) { Because 2521 is 4 numbers long, but it still doesn't work am I missing something here? Doesn't {} represent how long the integer can be?
-
Because I have forums where I only want a special link to show if the forum id number matches what's in a global value. so if forum id is like 26, and my global value is 2,5,27,21,26 and if it matches then I want it to show a special link for that specific forum (If it's a trading forum to be exact, I need to show a "Request a Mediator Link") so people can get help if they're trading or need to trade or need someone for help so I think it's easier if I just use the in_array function to check global id's and if the forum id is in there, then it will show the link, i think that's the fastest way? i might be wrong though let me check scoot's code and see what i can do Okay, this one works the best for me $input = '1,2,3,4,5'; if (!preg_match('/^\d+(,{1}\d)*$/', $input)) { echo 'invalid input'; } Thank you scootsa, I will jsut error out to the user if they indeed are trying to be nawty. Should I escape this too or it's fine? Im trying to learn not just steal code, so.. on this one $input = preg_replace('/([^\d,])+/', '', $input); Where does this show so it only accept's integers? I looked on how to find to match integers only.. http://stackoverflow.com/questions/9043551/regex-match-integer-only Looks like this does it ^\d+$ In your code u have the ^\d part, why is there a +$ sign? for what reason, makes it confusing. I dont want this topic to be moved to the regex forum, I just was wondering that. I looked at google and regex tutorials, where is a good place to start? https://www.google.com/search?sourceid=chrome&ie=UTF-8&q=regex+tutorial+detect+integer+only I tried this but cant find anything that would make it so I can detect integers only and strip them, like what you did. Thank you Im just trying not to just copy code from you guys like I used to, I want to actually learn this crap so I can ask less questions which I have been doing.. I think alot of people take advantage of this forum and dont realize the help they receive.. And I know I can be to quick to post sometimes, but it's just because I am really excited about what I am coding, or have no idea what im talking about
-
But how do I check input to make sure that the input has to be seperated by commas and has to be a integer like "1,2,3,4,5" is correct if a user puts "1,:25,,l2@" or something funky, I can error out Thanks also is there a php function that does this already? and is this way safe? im trying to store comma seperated id's
-
$db->query('SELECT id,username,star,color,actions from users WHERE actions >= 1 ORDER BY SUBSTRING_INDEX(\'actions\', \'|\', 2) DESC') WOW TOPIC SOLVED!!! Didn't know you could do this, wow I can store alot of information in explodes now and call them. AwesomE!
-
I dont understand the syntax mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2); -> 'www.mysql' is www.mysql.com supposed to represent the field name or? so something like this: SELECT SUBSTRING_INDEX('actions', '|', 2); ?