Tag Archives: php code

How to debug a php application in production/live mode

A simple way to debug a php application in production modeHow to debug a live website built in php?

Here’s a basic, simple and custom method i usually use to debug live or production web applications (web sites).

First of all i place the following lines of code in a config.php or somewhere so it is loaded in all targeted pages of the website. Continue reading

SQL dump file for CakeDC comments plugin for CakePHP

If they (CakeDC people) don’t have complaint of any kind or whatsoever i would like to post the SQL dump code for comments table used in CakeDC comments plugin. Especially, those having problems with generating database table or query through cake console could find this sql dump useful. But, before using this dump, please try to compare it with the latest schema file that could be found in config/schema.php file of the plug-in, it is possible that they might have altered the structure of the table in the meantime (It is Nov 02, 2010 today), so please use it at your own risk. Continue reading

Convert month name to month number in php

While working with a CJ run reports script i needed to convert “month name” into “month number” so i could store it in the database in date format. After doing some cleaning stuff i was ending with the month name, a three character string as “Jan”,”Mar”,”Apr” etc. Here is the quick work around i applied to get the month number automatically from the month name.

$month_name = "Jan"; //which i get from file name (Range_from_1_Jan_2009_to_3_Mar_2009.txt)
$month_number = "";

for($i=1;$i<=12;$i++){
	if(strtolower(date("M", mktime(0, 0, 0, $i, 1, 0))) == strtolower($month_name)){
		$month_number = $i;
		break;
	}
}

Now as php snippet code line 5 date(“M”, mktime(0, 0, 0, 1, 1, 0))) returns a three letter represantion of month name i get month “1” if i pass $month_name=”Jan” and so on. If i had full month name like “January” i could make it work by replacing “M” with “F” where “F” format parameter is a full represantion of year name.

Special Note: Do not forget to see user comments down the page to find even smarter solutions :)