The include and require functions are handy for using files that contain other variables, functions, etc. What happens when you have a collision between function names though? Well quite simply you get an error.
Last modification time
July 17th, 2006 by global in Quick Tips, PHPYou can use flat files to create a simple system to tell the last modification date of a file, but it's much easier than when you're using getlastmod(), no paramaters, it just returns the time stamp of the last modification, which you can pop into the date() function for formatting.
$last_mod = getlastmod();
$formatted = date("F j, Y g:i A", $last_mod);
echo("This page was last modified: ". formatted);
?>
It's that easy.
Generating a (semi) random string with PHP
July 17th, 2006 by global in Quick Tips, PHPIt's nice to have an easy way to generate a pretty much random string for whatever you want, especially passwords. There's a couple of ways to do it using PHP, and I'm going to show you one I learned from a friend of mine: Tim. This method just takes a random string, shuffles it around, and some characters from that string. It's a pretty easy method and can be condensed into one line if needed.
//Just a bunch of characters I typed
$string = 'dfsicjkxcvXSNxmaOZpqxnQDlaciwalaciAghakckUIy';
//Shuffle it up
$shuffle = str_shuffle($string);
//Get 6 random characters from the shuffled string
$random_chars = substr($shuffle, 0, 6);
//Condense into one line:
$random_chars2 = substr(str_shuffle('dfsicjkxcvXSNxmaOZpqxnQDlaciwalaciAghakckUIy'), 0, 6);
?>
Yay for random!
Pretty URLs using .htaccess
July 17th, 2006 by global in Web ResourcesURLs can either be ugly, or pretty. (hopefully they’re pretty) But most sites end up using the ugly structure:
Whilesites like ours use a cleaner structure:
Which do you like better?
replace method
July 10th, 2006 by global in JavaScriptThe JavaScript replace method allows you to replace one string with the other, e.g looking for recieve and replacing it with receive (rememeber, i before e except after c!) Using it is simple, the first paramater is the string you're searching for, the second the string you're putting in.
var correct = incorrect.replace("recieve", "receive");
That's all there is to replacing simple strings in JavaScript.
Make your own functions
July 7th, 2006 by Shwaza in PHP Tutorials, PHPMaking your own functions makes large projects so much easier when coding. I find, however, that not too many people who begin using PHP make their own functions, instead they repeat the same process over and over again, page after page. Believe me, I've done it!
Client-side isn’t always safe
July 5th, 2006 by Shwaza in Quick Tips, SecurityWith so many more people using all these fancy new techniques on their websites, you can begin to forget how insecure the client side really is. It’s very easy to manipulate content on the client side using browser add-ons and evening creating your own files and running them locally (providing the website isn’t checking referrers). This makes it extremely important that all validation is done server side, although there’s nothing wrong with doing it client side as well. I personally like having client side validation because it allows me to fix my mistakes without having to wait for the page to load and it also conserves server resources.
One thing I have to say is think about the user when implementing client-side validation. You should make sure that your validation is noticeable but won’t annoy the hell out of the user which could cause them to not bother and just leave. In my opinion the best kind of validation is altering the background color of the div (or *shudder* table cell) that the element with a problem is in. I find it clearly shows the user where the problem is but isn’t annoying or intrusive.
So just keep in mind that it’s find to use all the new effects and techniques, so long as you make sure you’re doing it safely and in an non-annoying and unobtrusive way.
You have ‘x’ number of characters left
June 30th, 2006 by global in Javascript Tutorials, JavaScriptFor whatever reason, you may have to limit the length of a message, be it for SMS or something else. A user doesn't want to have to guess the length, or run over to Word to find out. Using JavaScript, we can display the exact number of charaters left, and when the user goes over, we can show a warning.
ipbsdk
June 27th, 2006 by global in Web ResourcesThe ipbsdk is a cass for Invision Power Board (ipb) that allows you to control many aspects of the board, like adding topics, posting, checking user groups, and fetching PMs through a PHP class that you include in your custom scripts. This allows easy integration of ipb into other areas of your site, with the SDK, you could easily integrate the login on your front page with your forums. All functions are well documented, the current realease is 1.6 beta 4.
Select only what you need!
June 24th, 2006 by global in Quick Tips, SQLSelecting data from MySQL databases is easy, just run your query and it's done. I still see people using * in queries when they only need the ID or title, by using that *, you're selecting all the data, instead of just what you need. It's not that hard to select only one row, just specify it instead of putting a *.
You won't really notice a speed increase from one query, but running 30 queries multiple times a minute really adds up.
Get in Touch
Categories 
APIs (2)
C++ (1)
- C++ Tutorials (1)
cPanel (2)
CSS (7)
- CSS General (4)
- CSS Tutorials (3)
General Coding (1)
HTML (1)
JavaScript (24)
- AJAX (7)
- JavaScript General (5)
- Javascript Tutorials (16)
Odd Stuff (2)
PHP (61)
- PHP General (19)
- PHP Tutorials (40)
Quick Tips (12)
- C++ Builder (1)
- PHP (7)
- Security (1)
- SEO (1)
- SQL (1)
SQL (4)
- SQL General (4)
Web Design (4)
Web News (2)
Web Resources (19)
WordPress (6)
Latest Posts 
Tags
|







