Tuesday, November 25, 2008

Application Configuration

PHP applications come in many shapes and sizes. Some used locally from command line, and more commonly, for web based applications. More often than not, regardless of size or type, some form of configuration variables will be stored for global access. Usually these configuration options are held in one of these four types of containers.

* ini file
* XML file
* PHP file
* Database

Each options has its pros and cons. Here each of these options is explored to see which method is right for your application.

For more details head over at http://www.phpro.org/articles/Application-Configuration.html


Tuesday, November 18, 2008

GROUP_CONCAT in MySQL

I had the scenario for the table like below.

Table: test

id title
_________________

1 T2
1 T3
1 T1
2 L2
2 L1

I want the results like

id title
_________________

1 T2,T3,T1
2 L2,L1


For this, SQL would be

select id,GROUP_CONCAT('title') from test GROUP BY id ORDER by id


Now i want the values of title to be sorted.

This can be done using the below query

select id,GROUP_CONCAT('title' ORDER BY title) from test GROUP BY id ORDER by id

The results would be

id title
_________________

1 T1,T2,T3
2 L1,L2


Tuesday, October 21, 2008

Some useful Linux commands

Zipping the contents

tar -cvzf Destination folder Source folder from where files need to copy

Extracting the contents

tar -xvzf Source folder to extract

Zip the contents excluding the folders

tar -cvzf Destination folder Source folder from where files need to copy
--exclude="contents" --exclude="tmp"

To delete all occurance of files start with some extension

Eg:

find . -name ".svn" -exec rm -rf {} \;

Tuesday, September 23, 2008

Handling the Javascript Errors

1.Method using onerror event

onerror=handleErrors; //Invoke the method here

//Method definition

function handleErrors(msg,url,lineno)
{
//Here we will get the error message along with page url with lineno so tracking the error will be easier
//Handle the error here
return true or false
}


2.Try and Catch block

try
{
//Run some code here
}
catch(err)
{
//Handle errors using error object
}

Tuesday, September 2, 2008

Creating a Secure PHP Login Script

This morning i was going through some article which tells about the methods that we can approach for secure login.You can check it in http://www.devshed.com/c/a/PHP/Creating-a-Secure-PHP-Login-Script/

Wednesday, August 27, 2008

How to use MySQL REPLACE function

update my_table SET `my_field` = replace(`my_field`, "old_text", "new_text")

Head over for more details to http://www.webmasterworld.com/forum10/8113.htm

Tuesday, August 19, 2008

Picking datatype for status field

Quite commonly in the applications you would need to use some kind of “status” field - status of order - “new”, “confirmed”, “in production”, “shipped” status of job, message etc. People use variety of ways to handle them often without giving enough thought to the choice which can cause problems later.For more details on this topic you find it on http://www.mysqlperformanceblog.com/2008/08/09/picking-datatype-for-status-feilds/

Wednesday, August 13, 2008

How to filter posted data easily in PHP?

Today i found one good article on how to filter the posted data in php.You can find the same in
http://roshanbh.com.np/2008/08/how-to-filter-posted-data-easily-in-php.html#more-217

Tuesday, August 12, 2008

ab - Apache HTTP server benchmarking tool

ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.

You can find more details on how to use benchmark tool in below mentioned link.

Reference:

http://www.cyberciti.biz/tips/howto-performance-benchmarks-a-web-server.html