Scripts and functions that I have written or found useful

Archive for September, 2006

Reading in all POST and GET variables

Tuesday, September 12th, 2006 Posted in PHP | 1 Comment »

This simple one liner will read in all of the variables sent via POST and GET and turn them into relevant variables within this new page, so $_GET[variable] becomes $variable automatically. @extract($_POST); @extract($_GET); If this doesnt work, and some server setups stop your ...

PHP + MySQL Recursive Word Search

Friday, September 8th, 2006 Posted in MYSQL, PHP | No Comments »

This script will allow you totype asmany words as you like into a text box and find instances where all of these words exists in any field. The words entered only need to be seperated by spaces, no commas required! [php] $search ...

Simple php email script

Friday, September 8th, 2006 Posted in PHP | No Comments »

This is a simple email script which once uploaded, will send an email everytime the page is requested. It may be a good idea to add some security to this by restricting the destination email to stop spam[php] $subject = '' $destemail ...

Javascript automatically submit a form

Friday, September 8th, 2006 Posted in Javascript | No Comments »

Simply remove the sumit button and place this after the form. Once your browser reads in this script the form will submit. [javascript] document.form1.submit(); [/javascript]

Dynamic Date ticker/scroller

Friday, September 8th, 2006 Posted in Javascript, MYSQL | No Comments »

This is useful for displaying dynamic data in a small space, it scrolls the data and pauses at every line. It will also pause on mouseover [javascript] [/javascript]

Quick and simple Mysql connect

Friday, September 8th, 2006 Posted in MYSQL | No Comments »

This is the simplest and neatest way to connect to a MySQL database using php [php]$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("database_name"); [/php]

Dynamically read $_POST variables into an array

Friday, September 8th, 2006 Posted in PHP | No Comments »

[php] foreach ($_POST as $key=>$value)  $url .= "&".$key."=" . $value; [/php]

PHP Listing files in a folder

Wednesday, September 6th, 2006 Posted in PHP | No Comments »

This script goes through a given folder and finds all of the files and folders within. Using this script it is possible to recursively open up folders. [php] $PATH = $_ENV['DOCUMENT_ROOT']; $d=$PATH.'/home/server/public_html/folder/'; $files=array(); #initialize array $dir = opendir($d); while ($f = readdir($dir)) { if (eregi("\.php",$f)){ #if filename ...