This class will be used to custom the SQL Datetime format in your style. This may very useful for web developers to make their work easy. Class (Store as “sql.date.class.php“): <?php class FormatDate { public function Date($SQLdate, $format) { $maketime = strtotime($SQLdate); return date($format,$maketime); } } $dateobj = new FormatDate; ?> Implementation (Store as “index.php“): [...]
Archive for the ‘PHP’ Category
MySql injection protection class in php
What is Mysql Injection? SQL injection refers to the act of someone inserting a MySQL statement to be run on your database without your knowledge. Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a MySQL statement that you will unknowingly run on [...]
Alternate method for $_SERVER['SCRIPT_NAME'] to find exact filename
Now a days, all web developers/bloggers/SEO persons are using beautiful URL’s. Due to using beautiful URL’s, users can’t find, from which file name exact page is working. For Ex :- http://www.vijayakumar.org/profile/vijayakumar (It’s beautiful URL). But above mentioned URL will runs from file called profile.php [just guess]. How to find profile.php is a file? Is it [...]
Combine 2 MySql results using array on PHP
Main theme of this article is, searching values in 2 different MySql queries and combining both results as array using array_combine() and array_push(). Explanation is given under source code. <?php //connection parameters $username = “root”; $password = “”; $dbhost = “localhost”; $database = “test”; //Array creation $table1array = array(); $table2array = array(); $finalarray = array(); [...]
Easy Multilingual (English & Tamil) Website creation using php
This article will help you to learn how multi lingual web sites can be done by your own. This is a try by testing with 2 languages (English & Tamil). This may useful for web developers for creating multi language web sites. Ok, let we start.., It’s very simple work, by fetching data from 2 [...]
How to check online status for AIM, Yahoo!, MSN, Skype and ICQ users in PHP
You’re probably registered on at least one forum. And you’ve no doubt seen that in your forum profile, you can add your favourite Instant Messaging (IM) profile details, and other users can see if you’re online. You in turn, can see who else is online as well. Well what if you want to add that [...]
Bulk "One Line" PHP scripts
Below scripts will be more useful for PHP developers to make their coding fast and efficiency. 1) Eliminate duplicate (or more) characters in a string (the underscore in the example below): $text = preg_replace(‘#(_)+#’,'_’,$text); 2) Randomly select of one element out of an array: $image = $image_array[array_rand($image_array)]; 3) Pass the htaccess/htpassword authenticated user to a [...]
Zero fill a number using PHP
Have you ever needed to make sure your number is a certain length for output? Say you have the number 6 but need to make sure it is 4 digits and out put like: 0006. How would you go about this? One way to do this is the following: <?php function zerofill ($num,$zerofill) { while [...]



Posted in
Tags: