strtotime that accepts dates
Thursday, February 7th, 2008 Posted in PHP | No Comments »I got tired of writing many lines of code to simply add x amount of time onto a given date due to having to workout the linux timestamp for a certain date, then adding the date, then converting it back ...
Quick Email Function
Thursday, February 7th, 2008 Posted in PHP | No Comments »Its not the most secure email function in the world but if you want something quick or simple especially for testing then I use the below... function send_email($recipient,$subject,$body) { $headers = "From: Email System\n"; $headers .= "Reply-To: me@mydomain.com\n"; $headers .= "MIME-version: 1.0\n"; $headers .= "Content-type: multipart/alternative; ...
Shorten string length
Wednesday, September 26th, 2007 Posted in PHP | No Comments »$query = substr($query,0,-1); Shortens the string by one character. Change the second value to remove more or see php.net/substr for more information
Find and replace in mysql
Monday, September 10th, 2007 Posted in PHP | No Comments »To find certain characters or strings and replace them with another value, execute the following query... update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]'); This is quite useful for finding strange characters that appear instead of letters with accents over them. I usually replace ...
Pressing enter does not submit form
Thursday, September 6th, 2007 Posted in PHP | No Comments »Problem: pressing enter on form just refreshes page/ Pressing enter in textbox refreshes page All forms submit one of two ways... By clicking submit By pressing the 'enter' key Sometimes you may find that pressing enter only resubmits the form or appears to just ...
mod rewrite change php to htm
Saturday, August 18th, 2007 Posted in PHP, mod_rewrite | No Comments »Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^(.*)\.htm$ $1.php [L] If you change your pages from htm (or html) to php and want to maintain links particularly from Google then you can place the code above in your .htaccess file in the root ...
PHP Get last inserted ID from mysql
Saturday, August 18th, 2007 Posted in MYSQL, PHP | 1 Comment »$id = mysql_insert_id(); Each person on the website has a different session so if you use the above, it will automatically know which row was inserted last with this session. You do not need to worry about 2 people being on ...
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 ...