Hi ya guys,
Have you ever nested that many if conditions that your code starts to get quite complicated? Let's give you an example
Just some simple data checks on the $_POST['name'] value. But I'm not happy with that code. For something so simply, why is the code so complex? Let's use a technique with functions to make this much simpler. Then explain how it works in regards to simplifying it.
[code language='php']function get_name() {
//make sure it's set
if (isset($_POST['name']) == false) {
return 'Error Occured'; View In Full
I will quickly run you through an example of HOW to use memcache and how it works.
Download Memcache
http://jehiah.cz/projects/memcached-win32/
And load up the .exe - you should just get a blank command box appear - the server is then running on localhost:11211
Install the Memcache extensions in to PHP
If you use something like xamp or easyphp - just enable the memcache exentions (just a case of maybe uncommenting a line or ticking a box like in easyphp).
Code Example
Put that code in a .php page (remember to have the memcache server running). Now simply run the script and it will save my name in memory for 60 seconds! To retrieve the value from memory now put this in the script (within 60 seconds else it will expire from memory).
And you will see that my name is still there!
It's quite simple really. You use add() to add new values to memory where they are View In Full
Let’s go over what a session is.
Sessions
First you call session_start() which gives you a unique ID such as: dde2ds2g67xs2zxjh89s3j8923
Everything you then save to $_SESSION is saved in a file on the server such as:
$_SESSION['message'] = 'hello';
Would be saved to:
tmp/phpsess_dde2ds2g67xs2zxjh89s3j8923
and next time you call session_start(), $_SESSION['message'] will still exist and will have 'hello' in it!
Database Problem
So, you record a members total page hits on your site, and the last time they made a page hit on your site. You keep these stats up to date like this (which is executed on EVERY page hit by the member):
$time = time();
mysql_query("UPDATE `members` SET `timestamp_last_seen` = '{$time}', `hits` = `hits` + 1 WHERE `member` = 'VBAssassin' LIMIT 1;");
Now, all you’re doing is keeping track of the last time they were seen, and the total page hits they have made while logged in.
Solution
You need to keep track of your active sessions u... View In Full
Randomly pick an element out of an array, returns what was picked and removes the picked element from referenced array.
P.S. I've only been learning Perl for about 8 hours... so don't tell me off i
Specify an array of settings, and depending on the combination of settings will return a unique integer. This integer can then be used to workout the settings that were selected to produce that intege
Lets say you have 5 books... and 5 people rate each of those books. Now you want to find out who's interests, based on each users 5 ratings, are similar to who?
That's what this algorithm calculate
hey, hows the site going?
I got a new computer a while back, so I lost all my sites and stuff so I haven't been here for a while.
anyways, I decided to start programming again since its summer break and just remembered this site! I'm in high school and im trying to make a few bucks by putting together an online text MMORPG game.
Hey. Just wanted to let you know that A.) I read your reply, and I'm just can't wait to see things fall into place. Let me know when you start implementing so I can stare intently at the screen as things change. and B.) That I finally got around to submitting a source code, ActionScript 3, and I'd appreciate it if you took a look at it.
PS: Code highlighting seems to be a bit off when attempting to display notes between /* and */
Ahh. Thanks for the interest. It's not everyday that someone mentions my site, much less offers valuable advice ;)
As far as your forum goes, I would participate, but I'm far from advanced in any area of coding. So I tend to stay clear of it so I don't embarrass myself; however, I guess I could check it out more often.
PHP? I can update databases, load things dynamically, and a couple of other basic things. I'm still not very proficient in doing it securely :P
As of right now, I'm working on learning ActionScript 3.0, and then some website reconstruction.
Hey man, how's it going, well I actually enjoy the fleet, and now that I'm actually doing my job instead of learning it I love it.
Actually I work with Unix a lot out here, I'm actually going to a class on Goodfellow AFB in San Angelo, TX to learn some sysadmin about our system.
So far I'm way ahead of everyone else in my shop due to past experiances with *nix based systems, and my OIC (Officer In Command) said that once this other guy leaves (next year) I'm going to be the system administrator :)
As far as my fiance and myself goes, we actually got into a bunch of fights back in february and march and I left her about mid-march.
I kinda regret it now, but at least we are still really good friends, we talk every night and all so that's good :)
So ya, I was being an idiot and posted a comment that was meant for your profile on mine. So, here it is:
Ya. Understandable. I was told my numerous doctors and specialists back 4 or 5 years
ago, that I have severe carpel and I was told I was suppose to go and get surgery.
However, talking with other people who have had it - they had told me it helps for a
while, but then it fails. Also, another thing is the fact that I make a living
coding, and I was told that I would not be able to use a computer in the fact of
typing for at least 6 months. First thought was, HELL NO! And actually, that is still
my thought today.
If you do have problems with your wrists, what I had found was that if I woke up
mornings and it happened a lot where each morning my wrists would get worse and hurt
with extreme pain, etc. as soon as I woke up, wearing a wrist brace when sleeping
helped in the mornings along with the next day of sitting of typing. Just make sure
that the wrist brace if you do end up trying it is a solid brace not an only fabric
one, but one with a piece of solid plastic.
No, they abuse their power & get away with rubbish software at high costs No, they pick on smaller companies They're no different that other businesses Yes, some of their software is good Yes, i love microsoft, they do everything so well
please login to cast your vote and see the results of this poll