Archive for the 'Tutorials' Category

02nd Jan 2008

The easiest method to blocking websites

There are many ways to block a website - there are thousands of website filter software available these days, but the easiest way to block an unwanted website without installing any software is by editing hosts file. Yes, that’s right. I only found that out after reading Block Unwanted Websites - by just editing host file blog post on Techie Portal website. I knew about hosts file and I knew how it worked before I discovered the post but it has never come across my mind to use it as a way to block unwanted websites on your computer. Ah the little things that you overlook.

To find out more about how to block unwanted sites by editing hosts file, check out the original post.

Technorati Tags: , , ,

Posted in Tutorials | No Comments »

13th Aug 2007

Wanna learn PHP?

Recently, a few people have been approaching me with their interest in learning PHP and today, I came across this article PHP 101: PHP For the Absolute Beginner via Digg. Talk about timing!

This area is intended for everyone new to PHP. It opens with a series of informal, entertaining tutorials written by Vikram Vaswani, founder and CEO of Melonfire. These tutorials build on a previously-published 5-part series which has now been updated and extended to embrace PHP 5, making parts of it suitable for those of you who already have worked with PHP 4 in the past.

If you came here to learn about elementary PHP 4 or basic PHP 5, this is for you. Enjoy!

The tutorials are divided into 15 main sections as below:

  1. PHP 101 (part 1): Down the Rabbit Hole
  2. PHP 101 (part 2): Calling All Operators
  3. PHP 101 (part 3): Looping the Loop
  4. PHP 101 (part 4): The Food Factor
  5. PHP 101 (part 5): Rank and File
  6. PHP 101 (part 6): Functionally Yours
  7. PHP 101 (part 7): The Bear Necessities
  8. PHP 101 (part 8): Databases and Other Animal
  9. PHP 101 (part 9): SQLite My Fire!
  10. PHP 101 (part 10): A Session In The Cookie Jar
  11. PHP 101 (part 11): Sinfully Simple
  12. PHP 101 (part 12): Bugging Out
  13. PHP 101 (part 13): The Trashman Cometh
  14. PHP 101 (part 14): Going to the Polls
  15. PHP 101 (part 15): No News is Good News

Enjoy learning PHP!

Technorati Tags: , , , ,

Posted in Tutorials, PHP | 2 Comments »

05th Jul 2007

www vs. non-www 301 redirect

If you would like to force all your incoming URLs to have www at the front for SEO reasons, create an .htaccess file with the following content in the root directory of your website.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

What is 301 redirect?

301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It’s not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it’s the safest option. The code “301″ is interpreted as “moved permanently”.

Source: How to Redirect a Web Page

Technorati Tags: , , ,

Posted in Tutorials, Snippets | No Comments »

21st Jun 2007

Error logging in PHP

One of the most important tasks of any developer is to know what errors occur in his application, because it is impossible to fix them if you don’t know if they exist in the first place. Although you may think that your application is perfect and bugs free, you can never be 100% sure because users might not operate the application in the way you expect them to. And this is when error logging come in, where you record any errors that users encounter in a log file which can be used to improve your application. In PHP, you can control how errors are handled and reported. The following is an example of how errors may be logged:


// Error Reporting settings
ini_set('error_reporting', E_ALL ^ E_NOTICE); // log all errors except notices
ini_set(’log_errors’, true); // enable error logging
ini_set(’html_errors’, false); // disable html errors
ini_set(’error_log’, ‘/home/directory/to/your/error_log.txt’); // save all the errors to a log file
ini_set(’display_errors’, true); // do not display errors on screen

Related articles:

Technorati Tags: , , ,

Posted in Tutorials, Snippets, PHP | No Comments »

18th May 2007

SQL Injection Demo

Always wondered how SQL Injection works? Check out the following demo video.

Technorati Tags: , , , ,

Posted in Tutorials, PHP | 3 Comments »