Search and Replace in MySQL

Often your MySQL database is so large that if you want to find and replace a given entry, it will take days. This is when this simple snippet comes handy:...

Credit Card Validation Function

Whethere you are building a shopping cart or just requesting your customer’s credit card number for some purpose, we are constantly faced with abusers that fill invalid or fake credit card numbe...

Simple Random Password Generator

This is a simple script that will generate a random alphanumeric password with customizeable lenght. [ad name=”In Post”] Usage is as follows: The example above will return a random passwor...

Set PHP Script Timeout

Most of the times the PHP script timeout is set by default by your hosting company to 30 seconds. This means that after 30 seconds of running, your script is immediately killed, which means that all t...

Simple PHP Script to Send Email with Mail()

There are three requirements for sending email through a PHP script: A form, an email processing script, and PHP’s mail() function to be enabled (most hosts have this enabled, but some shared ho...

How to Create a PHP Redirect?

Sometimes you want to hide an affiliate link, sometimes you may want to log each downloads of a file or just redirect the user to a site through your script. This is where PHP redirection comes handy....

Download Remote File Using CURL and PHP

Sometimes you need to download URL’s contents using the CURL library, included inside PHP (e.g if you want to use a web-based API, provided by service like TinyURL, Digg, Twitter). It’s ac...

PHP Script to Show Visitor’s IP Address

Sometimes you want to get the visitor’s IP address (e.g to show it to him or for logging purposes). This simple snippet does the job: $ip = $_SERVER['REMOTE_ADDR']; Also, if you have REGISTER_GL...

Top Online IDEs to Test Your PHP Code

Sometimes you don’t have an Apache server on your PC and you don’t want to go through the hassle of uploading your PHP script to your web hosting space just to test if your tweaks inside t...

Convert Text to Barcode Image

Thanks to a skilled PHP programmer, the internet has a ready made PHP script that takes a text string and returns an image representation in barcode format. Here’s the complete script: =1 to ena...

How to kill PHP (on purpose)

1. Stack overflow (e.g calling a function inside itself). function a() { a(); } a(); First you define a function called a() and the function’s sole purpose is to call itself again, causing an in...