Monkuar
Members-
Posts
987 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Monkuar
-
Topic Solved
-
Their precedence values. In your particular usage they both have the same end result. If you have a list of values to check against a variable using an OR condition, you can use in_array as a cleaner method of doing it. I find it doesn't really matter much until your at 3 or more values though. $values = array('/pmi.php', '/pmsent.php'); if (in_array($_SERVER['PHP_SELF'], $values)){ ... } Lol! At 3 more values? Speed wise, what do you suggest? the old fashion if ($_SERVER['PHP_SELF'] == '/pmi.php' OR $_SERVER['PHP_SELF'] == '/pmsent.php'){ $location = 'Using Messenger'; }else{ $location = ''; } or $values = array('/pmi.php', '/pmsent.php'); if (in_array($_SERVER['PHP_SELF'], $values)){ ... } Speed wise is there any noticeable difference? This will be run with each refresh for each user on my forum.
-
What's the difference between || and OR ?
-
if ($_SERVER['PHP_SELF'] == '/pmi.php' OR $_SERVER['PHP_SELF'] == '/pmsent.php'){ $location = 'Using Messenger'; }else{ $location = ''; } I wanted to use if ($_SERVER['PHP_SELF'] == '/pmi.php' OR '/pmsent.php'){ $location = 'Using Messenger'; }else{ $location = ''; } But that doesn't work, I need to check pmi.php, pmsent.php and pms.php, but I don't want to use if $_SERVER['PHP_SELF'] == BLA OR $_SERVER['php_selft'] again.. blah thanks
-
The cookie has no value, it simply exists. Basically if it exists, don't add a view, if it doesn't exist create it and add a view. How would you differentiate between each post/image they're viewing? I am trying to do the same thing for a system of mine. If a user has viewed the topic in less then 24hours, store the id's in a array, and if it exists, echo NO SQL to update+view, would that be the same case here?
-
Whats the value of the cookie user? Im lost, I am actually doing something similiar to this also. Are you going to be storing them id's of the images in the user cookie and check fi they already visited or what?
-
Oops, I made a thread about you, didn't see this one! Well you can have 2 now ! HAahah. Enjoy!! nice Tag Why am I only the "non-mod" posting here? Salathe Edit: I merged your thread into this one, your post is up above.
-
Congrats on your new Guru tag!!! CHEERS http://www.phpfreaks.com/forums/index.php?action=profile;u=129745 Congrats man, well deserved imo, you're a awesome helper, same for physo,thorpe/etc maniac dan/etc. W/o you guys tbh, I wouldn't be where I would be now.. it's amazing how we can come together in a small world and teach so much.. Good work man
-
how to increment value and add a another value?
Monkuar replied to Monkuar's topic in PHP Coding Help
Hey, I'll use Muddy_funster's way, just because Im not going to be selecting any data from this field, just displaying it, so holding the data is fine for what I am doing, but I understand you and where you're coming from, it's prob bad to store values in explode if they're going to have to be selected later, but as of right now it's just a info it's fine and will never have to be selected again I'll use muddy_funster's way for this, didn't know concat did that, will look into concat's function @ mysql and learn some more goodies, Thanks Muddy Topic Solved -
$db->query('UPDATE users set actions=actions+1|'.time().' where id = '.$pun_user['id'].''); im trying to do set actions=actions+1, then put a | atfter +1ing it, then add my time stamp to it so I can explode it later. so it will look like this 2|unixtimestamphere how would i achieve this? or do I need to make another seperate row? seems dumb
-
WoW, 3:28am here for a reason, and you saved the day, good work man, lol topic solved Brain fart or something marked as solved ofc ty thorpe
-
okay in modlogs.php i have a function <?php function modmenu($page) { ?> <dl><dt class="<?php if ($page == 'modlogs') echo '';else echo 'ust'; ?> LEFT" style='margin-left:5px'><a href='mlogs.php'><b>User Logs</b></a> </dt><dt class="<?php if ($page == 'modlogs1') echo '';else echo 'ust'; ?> LEFT"><a href="modlogs1.php">Topic/Forum Actions</a></dt> <dd> <?php } ?> in modlogs1.php i try to echo modmenu('modlogs1'); to show the menu but i get unidentified function? lol isn't functions global wtf?
-
I am using a cache script, well it writes a array to a file like this: fwrite($fh, '<?php'."\n\n".'define(\'PUN_LOTTERY_LOADED\', 1);'."\n\n".'$lottery = '.var_export($output2, true).';'."\n\n".'?>'); output2 is $result2 = $db->query('MY QUERY '); $output2 = array(); while ($cur_donors = $db->fetch_assoc($result2)) $output2[] = $cur_donors; Now, I want to ditch the mysql and I want to use this script with 7 variables that I already have loaded, so I dont need to use the mysql, how do I add my 7 variables to my var_export function instead of using mysql to loop them?
-
You meen you want to impersonate 500 users hitting your site? Why don't you just ask that question. Jeeze! Take a look at http://httpd.apache.org/docs/2.0/programs/ab.html LOL, awesome!! This will most likely lag up my pc abit on localhost I imagine? I am going to try to do this stuff asap! Cant wait, this looks like it will be alot more beneficial then my current idea, lmao
-
What your trying to describe there sounds terribly inefficient. You should be able to select all of a users info using a single query. Turn on SMF debugging and look at the bottom i am talking about: Page created in 0.071 seconds with 7 queries. See how it says 7 queries? mine is 8 so that's what i meant, i need to have 500 people refreshing and using those queries for my test, cant figure how to do that on localhost
-
That doesn't make much sense to me. If the Web server and the Database server are on the same machine, then everything is happening in the same machine and I don't think there is any bandwidth to monitor. If they are on separate machines then there would be. But, the amount of data for 500 records would probably be so small it would be difficult to even measure accurately. Well these 500 records are for the online table, so im trying to represent 500 people online in a forum. (im trying to do concurrent connections, 500 of em) each connection has 8queries to select all member info and to call the forum page/etc
-
Oh, well because I did some tests and I thought the memory usage was the same as the bandwidth usage: http://fluxbb.org/forums/viewtopic.php?pid=45146#p45146 I got owned by the developers because I thought memory usage was = bandwidth usage. Now I need to find out how to test the bandwidth on localhost with 500 rows inserted, or not. Any idea mate?
-
the difference between memory usage and bandwidth usage? I did a test with 500 rows in table, got 2.36mb memory usage, and then once without 500 rows in table, i got 2.34 (IN MBS) memory usage, can that translate into bandwidth usage? somone told me that bandwidth usage != memory usage, how so? it does effect it some doesn't it ?
-
sweetbro, Thank you $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $time_diff); fclose($fh); Now $time_diff is my milisecond variable to show how many ms it is, But how do I make it so it doesn't change the whole file and replace it with the milisecond, I need it to add the data below data inside a text file. What it does is every refresh it changes it "0.0106" I Need it to do "0.0106 0.0101 ,so on" so it stores the stuff. Cant seem to find out with fwrite to accomplish this fwrite($fh, $time_diff."\n"); fixed ty topic solved
-
Not exactly, microtime() is simply to get the current timestamp in milliseconds. So, if you capture microtime() two time you can calculate the amount of time it took to perform the tasks between those two instances. You can even capture the time in multiple instances of the script to determine performance of specific things in the script. $begin = microtime(true); //true returns the microtime as a float value, so we can do maths with it. Without this, it'd return a string and need typecasting, or otherwise over complicate it... //write some awesome, fast PHP code here. $end = microtime(true); //we've discussed this. echo "Time taken: ", $end - $begin; So for this, on my forum software I am making, I should put $end = microtime(true); at the bottom of the global footer to get the correct time. Then can I store that and write it into a text file using $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "Floppy Jalopy\n"; fwrite($fh, $stringData); $stringData = "Pointy Pinto\n"; fwrite($fh, $stringData); fclose($fh); something like that to store the seconds? then I can refresh page 100 times and get then look at the results? Would that be a fair benchmark imo or?
-
does this microtime feature/etc benchmark query performance too? I mean when it echos out in miliseconds the time it takes for a refresh, does that count the mysq queries too? or just php
-
Theres no way in hell I think you can hide source code, maybe a js encrpytion but i really dont think u can bro
-
I want to do a test while refreshing the page 100 times with 500 rows in a table, and then without 500 rows in a table and with different kind of php code, i need to do some type of testing to get results back in to show which way is faster for mysql/php. Any idea how to do this any scripts out there or a built in php/mysql function? Thanks
-
Okay awesome if (isset($_GET['hide'])){ $id = intval($_GET['hide']); $explode = explode(",", $_COOKIE['hide']); $id = $id; $array = $explode; if(in_array($id, $array)){ $array = array_diff($array,array($id)); setcookie('hide', implode(',', $array), time()+32000000); }else if ($_COOKIE['hide'] AND $explode['1'] AND $explode['2']){ setcookie('hide', ''.$explode['0'].','.$explode['1'].','.$explode['2'].','.$id.'', time()+32000000); }else if ($_COOKIE['hide'] AND $explode['1']){ setcookie('hide', ''.$explode['0'].','.$explode['1'].','.$id.'', time()+32000000); } else if ($_COOKIE['hide']){ setcookie('hide', ''.$explode['0'].','.$id.'', time()+32000000); } else{ setcookie('hide', ''.$id.'', time()+32000000); } header('Location: index.php'); exit; } my new code works awesome bro Thanks for your help. Marking as Resolved!!
-
Hey, this works but what if I want to add to the array instead of take away stuff? Is there a different function for that? I added this else{ setcookie('hide', ''.$id.'', time()+32000000); } to the end, so it can just add the ?hide=1 if somone clicked, so it will actually set my cookie value, but then now if the user clicks on ?hide=2, it will launch this again because that $id is not matching the in_array