User Name
|
VBAssassin |
Unique Hits
|
4,413 |
Real Name
|
Scott Thompson |
Location
|
United Kingdom Lincolnshire |
Occupation
|
Web Technologist & Director |
Gender
|
Male |
Age
|
21 Years Old |
WebSite
|
coderprofile.com/ |
|
|
[PHP] - Lets kill the complex IF
Programming
|
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
 |
3 Comments |
7.00 out of 10 |
|
|
How to use Memcache on Windows
Web Development
|
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
 |
3 Comments |
8.00 out of 10 |
|
|
PHP Sessions = Member Database Cache
Web Development
|
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
 |
2 Comments |
8.00 out of 10 |
|
|
|
Dynamic Parameters (Using Reflection)
PHP (Hypertext Preprocessor)
|
84 Days Ago
|
7
|
7.75
|
- - -
|
2,468 Chrs
|
|
Allows for you to call a method of a class with the parameters in no particular order! Example:
function print($string, $size = 12, $color = 'red);
If you want to skip size, but you want to chan
|
|
|
Slime Wars Game v1
PHP (Hypertext Preprocessor)
|
113 Days Ago
|
2
|
- - -
|
Yes
|
1,903 Chrs
|
|
Good old slime wars game where you have to try and win by having your colour dominate the board. Simple enough...
I plan on hosting this game on a domain name of its own when i update it to version
|
|
|
Pagination Class
PHP (Hypertext Preprocessor)
|
153 Days Ago
|
2
|
8.50
|
- - -
|
4,548 Chrs
|
|
Takes care of the hard work when creating pagination and can carry across variables between pages in the pages URL. Multiple instances of pagination can be used on a single page.
|
|
Please login to post comments. |
|
Hey VB! To be honest, I'm not really sure where it came from. I was just sick of seeing the same old little symbol for not having an avatar. So I just found that one on the internet lol.
|
|
Database-supported websites and backends aren't complicated. I like it to find ways to handle real-files. I think this is a good argument: without files - no database-connection. Thus files have a primary priority :)
Seriously: I know from my dads work, that several webmasters work without dbases... Gee! With real html-files... plaintext. Age Tea Am Al... It sounds like 48 years old hirsute Al in lumberjack shirt at teatime with his affectionate mum. omg... Said webmasters looks like "Al". I've seen some. You can find Al's anywhere: mostly in the metro and at McDee.Handwritten er from Dreamweaver.
Never heard from dynamics... whysoever. As long as dbaseless backends are not absolete, I think it's a vital part to find cool ways to manage this crud... uhm... stuff :)
|
|
Hey, thank you :)
Yeah, I'm fine. I've many ideas to write a little framework with readdir-, template-, multilanguage-, permissions-support - all without database. But with xml-/xhtml-dataoutput: data preparation for the browser and for flash-movies :)
And thereafter I will write an installation-application for webmaster; 'cause, I've seen by my dad that the most tasks repeat if he create a clients webpage. My idea: open a form at your apache, insert the global page-data (title, clients-data), create menu-/data-structure and let write the complete page automaticially by PHP.
The only two things wich will you do, are the special-stuff:
I believe, if the "routine works" complete, you have more time to write your perfect html-design and more time for the database-architecture, if your website runs by mySQL.
The concept is fine... Okay: I've no idea how can I include add-ons :(
But I think, thats a great idea to save much time.
And how are you? All ready? You're healthy again?
Oh so, my ickyfreaky avatar is also a marionette from my mum :)
PS: I'm sorry for my abysmal english :P
|
|
VBAssassin.
Guess who's back ;)
|
|
I'm good, just got back from an e-business exam, all about database transactions and auction mechanisms. fun :)
I just want a site for testing / hosting small sites I want, need mysql, php, and cron. I currently have a godaddy sharted hosting for a site i manage, I found alot of hosts I tried block external file access, I need that.
Was looking for a domain name to host my testing stuff on, any suggestions? wanted something to do with my name, or coding, or something..
|
|
Hey, on VS.PHP 2.5, do you have the full edition of Visual Studio? I downloaded the Express edition and it wouldn't let me install. WTF!?
I guess I'll have to download VS2008 then lol.
|
|
Well the 2651's do, but the main OS I am working with is SunSolaris, not really a big fan of it but, oh well
|
|
Yeh man I love Ubuntu, right now I'm just having trouble getting it to recognize my wireless card, but I'll download the drivers tonight and that should fix the problem.
Finnally set my laptop to a dualboot instead of just running it in virtual box woot! hehe
|
|
Chat rooms eh? What are these going to consist of? IRC-like?
|
|
Yeh I am a little annoyed but yet again I'm greatful because all the benifits I get she get's to so I'll be able to provide a good life for her and in the future when we have kids they'll grow up in a good home.
Also I'm trying to get in a non-deployable detatchment so I won't be going over seas, it'll be just like a normal job, 8 hrs a day, then PT (Physical Training) then I go home the rest of the day.
Plus we won't have any bills, to pay, and all of our meals are free, thanks to the Corps.
|
|
 |
Scott Thompson (21) United Kingdom, Lincolnshire |
|
VBAssassin has 26 fans
become a fan |
|
 |
|
 |
|