Wednesday 29 September 2010

How to create Custom Error Messages in Apache?

Below is the way to create custom error message using Apache:

Below is an example of a .htaccess file, just copy and paste into your file, but change the paths:
ErrorDocument 404 /path_to_your_error_file_or_script
ErrorDocument 403 /path_to_your_error_file_or_script 
ErrorDocument 500 /path_to_your_error_file_or_script

Examples:
Full path would be http://www.yourwebsite.com/path_to_your_error_file_or_script
Absolute path would be /home/yoursite.com/path_to_your_error_file_or_script
Relative path would be /path_to_your_error_file_or_script
To summarise the steps, they are as follows:
  1. Create a text file, and add to it a line for each error and rename it .htaccess
  2. Upload the files/script that the .htaccess file calls in each error.
  3. TEST! By typing a weird URL in the address box - you should get the 404 custom error.
Now you are done!

Cheers!

How to store UTF8 (indian language) data in mysql?

We assume we have a DataBase with table news, and a column named posts, which will save the news written in your website.We know that all major DataBase’s support UTF8. And we shall explore that feature.
Now we write a article in hindi, हेल्लो वर्ल्ड
If the UTF8 is not specified, you should see something like ?????? in ur DataBase otherwise you should see the hindi data. Clear? Now lets see the code given below:


First check for UTF8 compatibility with this query. If it supports you should see the output as “Character_set_system”| “UTF8″
SHOW VARIABLES LIKE ‘character_set_system’;
this will show the below result if support:
Full Texts
Variable_name    Value
character_set_system    utf8


Now that being checked, alter the table and just modify the column, which is 'text' in our above example and specify it as UTF8
ALTER TABLE news MODIFY text VARCHAR(200) CHARACTER SET UTF8;

Then execute following query before inserting into the table:

mysql_query('SET character_set_results=utf8');       
mysql_query('SET names=utf8');       
mysql_query('SET character_set_client=utf8');       
mysql_query('SET character_set_connection=utf8');
mysql_query('SET collation_connection=utf8_general_ci');


 
Now, try to insert the hindi value and save it. Query it and u should see the hindi text :)


 Cheers!