Monkuar
Members-
Posts
987 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Monkuar
-
Here is a update: I got it to work but using a long and exctrucinating method, I would love if anyone could help simmer down my code a bit, using foreach or something? because I will have to do this for all 70, can't it be done using a array 1-70 or something alot easier? HTML: <input type=radio id='s1' value='1' onclick='showPreview(1)' name='star' $checked1><label for='s1'><img src='style_images/1/icons/1.png'></label> <br> <input type=radio id='s2' value='2' onclick='showPreview(2)' name='star' $checked2><label for='s2'><img src='style_images/1/icons/2.png'></label> <br> <input type=radio id='s3' value='3' onclick='showPreview(3)' name='star' $checked3><label for='s3'><img src='style_images/1/icons/3.png'></label> <br> <input type=radio id='s4' value='4' onclick='showPreview(4)' name='star' $checked4><label for='s4'><img src='style_images/1/icons/4.png'></label> <br> <input type=radio id='s5' value='5' onclick='showPreview(5)' name='star' $checked5><label for='s5'><img src='style_images/1/icons/5.png'></label> <br> <input type=radio id='s6' value='6' onclick='showPreview(6)' name='star' $checked6><label for='s6'><img src='style_images/1/icons/6.png'></label> <br> <input type=radio id='s7' value='7' onclick='showPreview(7)' name='star' $checked7><label for='s7'><img src='style_images/1/icons/7.png'></label> <br> <input type=radio id='s8' value='8' onclick='showPreview(' name='star' $checked8><label for='s8'><img src='style_images/1/icons/8.png'></label> <br> <input type=radio id='s9' value='9' onclick='showPreview(9)' name='star' $checked9><label for='s9'><img src='style_images/1/icons/9.png'></label> <br> <input type=radio id='s10' value='10' onclick='showPreview(10)' name='star' $checked10><label for='s10'><img src='style_images/1/icons/10.png'></label> PHP: switch ($ibforums->member['star']){ case '1'; $checked1 = 'checked'; break; case '2'; $checked2 = 'checked'; break; case '3'; $checked3 = 'checked'; break; case '4'; $checked4 = 'checked'; break; case '5'; $checked5 = 'checked'; break; case '6'; $checked6 = 'checked'; break; case '7'; $checked7 = 'checked'; break; case '8'; $checked8 = 'checked'; break; case '9'; $checked9 = 'checked'; break; case '10'; $checked10 = 'checked'; break; }
-
Long story short, this is my code: <input type=radio id='s1' value='1' onclick='showPreview(1)' name='star' $value><label for='s1'><img src='style_images/1/icons/1.png'></label> <br> <input type=radio id='s2' value='2' onclick='showPreview(2)' name='star' $value><label for='s2'><img src='style_images/1/icons/2.png'></label> <br> <input type=radio id='s3' value='3' onclick='showPreview(3)' name='star' $value><label for='s3'><img src='style_images/1/icons/3.png'></label> <br> <input type=radio id='s4' value='4' onclick='showPreview(4)' name='star' $value><label for='s4'><img src='style_images/1/icons/4.png'></label> <br> <input type=radio id='s5' value='5' onclick='showPreview(5)' name='star' $value><label for='s5'><img src='style_images/1/icons/5.png'></label> Somehow I need to try to get my $value to equal 'checked' based upon my "star" variable: So I choose #5, which is <input type=radio id='s5' value='5' onclick='showPreview(5)' name='star' $value> and now my "star" value is set to 5, (I updated it through my db) how do I make $value become 'checked' when I have 4 others input type=radio's that it will check also? I only need the #5 one checked as that is one that I chose. The problem is, I have 70 of these input type Radio's and if I use $value on every one it will not show them all checked instead of just the 1 i chose
-
I don't necessarily need php Help, but some Logic!
Monkuar replied to Monkuar's topic in PHP Coding Help
very good idea thank you this is what it looks like so far: This helps to show, people who donated 5 Dollars, will get access through 1 through 10 stars.png. -
Hey guys, I am not really asking for pure php code, as I know alot of if's and switches could do this, but I am thinking of a easier method, of using for each or something to make it alot more better (performance wise) here it goes. I have 70 images, 1.png to 70.png, they are STARS. People on my forum software can upgrade there account via paypal to become a "Site Donor" I use the paypal's IPN to update the "amount" field value in mysql for each member. So if a user donates 10$, and then he donates 10$ tomorrow, the "amount" field will have a total of "20$" in it. Now I need to show a page where it list's all 1-70.png STARS, and it will have a radio button next to each star for them to select (Based on the amount they donate) So if a person has only dated 5$ dollars, they will have access to starts 1 through 10.png. If a person donated 20$ they will have access to 1-20.png Stars to chose from, (and so on) What would be the easiest way to check the input so people can't tamper with my form value to get a let's say 50.png star when they only donated like 10 dollars? Should I use just a simple switch function with 70 Cases? Or is there a easier method? and how would I go about storing a value in a field when they make a payment so then I can just simply check that field with the users input so they can't tamper the data and try to get a higher star?
-
Need to replace ' and " and all html entities... I cant :(
Monkuar posted a topic in Javascript Help
var str = document.REPLIER.Post.value='{$ibforums->input['Post']}'; document.REPLIER.Post.value = str.replace(/<br\s*[\/]?>/gi, "\\n"); Okay this above code works very nice, it replaces all the <br>'s with \\n so when people press "enter" it doesn't show the whole form with <Br>'s But I want to make it so so if somone enter's a ' OR " OR any other html char, that is converts it back to the same the thing I entered.. instead of "#&39;" or whatever... Example: If I click on Preview Post, it passes through server side ofc to check my bbcode parser, but then it spits the "#&39;" back at me in my editing field which is my code I showed you above! I already converted it so it show's \n instead of <br>'s so it's nice. but now I want to convert the #&39; back to " ' " or any other entity back to it's original character EDIT(Yes I do check my inputs server side, for html tags/etc, but since the editor is client side it converts them back to the #&39; stuff which I need to be converted back to the original state of the character. Please help, (Hell even if jquery can do this I am down).. -
WOW count function i am a idiot, Topic resolved ty
-
Hey, I am echoing out: $source = implode(',', $arr2); echo $source; which is a array, and it echo's out: "2,2,2" I am trying to find a php function to add each array, so the result will be "6". Possible?
-
$DB->query("SELECT tid FROM reports WHERE id IN ($ids)"); $arr = array(); while ($max = $DB->fetch_row()){ $arr[] = $max['tid']; } echo implode(',', $arr); Topic Resolved!
-
$DB->query("SELECT tid FROM reports WHERE id IN ($ids)"); while ($max = $DB->fetch_row()){ echo $max['tid']; } This code spits out: 12012167 It's grabbing 120, and 121 and 67. Those are my "tid" for each column in my database "reports" The problem I am trying to make it echo 120,121,67 So I use the explode: $tids = explode(",", $max['tid']); echo $tids; Then it echo's out. ArrayArrayArray Any idea guys?
-
I clicked it 3 times, so it ad's my $_GET['hide'] 3 times, which should be 3,3,3? No idea why it's not working Other websites, it is shown 3,3,3 too. why Can't I get mine like that? Easier to explode.
-
My code here setcookie('hide_div', $_COOKIE['hide_div'].','.$_GET['hide'],time()+32000000); When I set it, it works wonderful, but then when I see view it in my cookie it shows this code between my $_GET['hide'] values %2C how do I clean it up and just make it show my " , "? Thank you
-
I just did return $x .'ago'; wait, doesn't work it shows 2 " ago's " I will try your way, and just have to manually edit each time it is called. let me see Thank you so much, was editing bunch of stuff for ages couldn't get anything to work. II am very happy. Resolved
-
Okay, I need to make it so it shows " ago " after the time it states. It shows "2minutes 20 seconds" but I can't figure out how to make it say "2minutes 20 seconds ago" (simply just need to add "ago" after) This uses alot of ternary operators, and I am not very knowledgable in that area, so if You can help, it would be great. 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; } Simply, just need to add "ago" somewhere, but I can't figure it out, this uses unixtimestamp also.
-
var lol="hey <br>"; document.REPLIER.Post.value=lol.replace(/<br\s*[\/]?>/gi, "\n"); I am trying to replace all <br> tags in my var "lol" but I get the "unterminated string literal" error on line 2 which is: document.REPLIER.Post.value=lol.replace(/<br\s*[\/]?>/gi, "\n"); Any help?
-
Wow, the problem was: I had to add: $this->timeAgo($_tm, --$rcs); Because I guess I was calling it from a different .php file, this is in functions.php, and where I am calling it is in skin_profile.php. I feel like a fool and sorry for wasting everyones time, lol I guess it just helps me to explain my code more out and I can understand it more? Thanks all for trying. I am going to mark this Resolved.
-
I know it works, but it brings the error when I try timeAgo($member['last_activity'],2); Whenever I try to add the ,1 or ,2 or ,3 to show "2minutes xx seconds ago" or whatever, instead of just the "2 minutes ago" Try that way, and let me know ty
-
Hello, I have this script that converts my unixtimestamp into "XXXX Ago" time format. function timeAgo($tm,$rcs = 0) { $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 .= timeAgo($_tm, --$rcs); return $x; } This is how I use the script on my forum script/site. timeAgo($member['last_activity']) $member['last_activity'] is a unix Timestamp. This works wonderful! but here's the problem! I am trying to make it go 2 levels more. Like instead of just "2 Minutes ago" It says: 2 Minutes 20 seconds ago So then I apply how to do that: timeAgo($member['last_activity'],2) See the number 2? Then all of sudden I get this weird ass error... Fatal error: Call to undefined function timeAgo() in myscript.php on line 1187 1187 line is: if(($rcs > 0)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= timeAgo($_tm, --$rcs); Why would it say undefined function when it's in it's own function? This is weird as hell I am absolutely stumped, any help would be appreciated.
-
Hey, I found this in some other code somewhere else: $val = str_replace( "<" , "<" , $val ); I guess this was the culprit.. wow Facepalm me, I was looking at the source and it had the characters < I was thinking to myself, does it auto convert into that normally? Doesn't it need a str_replace to get into that kind of code? (While viewing source), so I want to say Thank you pikachu for telling me about viewing source, I know I should have, and I will continue that in my future of coding, if I am stuck. I learned a big lesson here and I am thankful for you guys helping me. Wow, ManiacDan, so sorry for giving you a hard time, I bet you were like "WTF" Thanks again all, I am going to mark this as Resolved. I am extremely Happy.
-
Wow this is really frustrating, Thank you both for your replies, unfortunately it's still not going through. I even tried: '#\b=]\b#i' a smiley =] and it works fine but whenever I put in the < character it seems it does not work, it accepts every other character though, do you think i need to have something in php to enable something like this? I do have this code that is below this code: $txt = preg_replace("/&#([0-9]+);/s", "&#\\1;", $txt ); But I removed it just cause, and hell it's still not reading my "<3" I can use the LETTER "5" and it works, but not "<3" anything with "< or >" just messes it up and doesn't go through, I am simply dumbfounded
-
Nope, I can remove the 5 and it's still the same. I am really stumped on this, could you look over it 1 more time, please, how is it working for you? you're not using arraY_keys like me though, try my function at home and see if it works.
-
Hmm Sir, let me show you my full function then maybe will help, cause I copied your "#(?<!\w)<3(?!\w)#i" and it's not working still. Here you go mate: $smilies=array ( '#(?<!\w):thumbsup:(?!\w)#i' => '<img src=html/emoticons/thumbsup.gif alt=":thumbsup\:">', '#(?<!\w)<3(?!\w)#i' => '<img src=html/emoticons/heart2.gif alt="<3">', ); $txt=preg_replace(array_keys($smilies), array_values($smilies), $txt,5); It's not replacing the <3.... really dunno what is problem, is it because of the array_keys?
-
This code WORKS FINE: '#(?<!\w):thumbsup:(?!\w)#i' => '<img src=html/emoticons/thumbsup.gif alt=":thumbsup\:">', so Whenever I do :thumbsup: in my post, it makes the thumbsup smiley! it works nice! but I need the following to work: '#(?<!\w)<3(?!\w)#i' => '<img src=html/emoticons/heart2.gif alt="<3">', See how I want to type "<3" to get my heart2.gif showing? For some reason it's not passing through and displays nothing, I tried to do <\3 but it still won't work, any ideas? I need to escape somethiing because of the "<" character is messing me all up. Thanks for the help
-
Thank you for your help,topic solved.
-
$replace = array(""=>"<img src=html/emoticons/smile.gif>", "2"=>"b", "3"=>"c", "4"=>"d", "5"=>"e"); $txt = preg_replace("'(|2|3|4|5)'e", '$replace["\1"]', $txt, 3); I am trying to put in the regex pattern, but it works, but it's letting me use more then just "3", I need to edit the ("'(|2|3|4|5)'e", '$replace["\1"]', $txt, 3) Code so I can get the " " to work correctly. I tried: ("'(:\)|2|3|4|5)'e", '$replace["\1"]', $txt, 3) But still is letting me post more then 3. I tried: ("'(\:\)|2|3|4|5)'e", '$replace["\1"]', $txt, 3) With 2 \'s but still wont work. Any help guys? :confused:
-
$ibforums->input['Post'] = str_replace ( "'", "\"", $ibforums->input['Post'] ); Thanks! Topic resolved!