29 May 2011

Enable double escaped sequence in IIS 7

HTTP Error 404.11 – URL_DOUBLE_ESCAPED 

Add the following code in application host file and it will allow double escaped sequence for the default website and those child websites under it.
Open %windir%\System32\inetsrv\config\applicationHost.config

Details # http://support.microsoft.com/kb/942076

26 May 2011

Mysql Introduction - Php For Beginners - Lesson 10

Databases are very important in the field of web development. A database is a collection of data in a very organized fashion. By organized fashion it is meant that the data will be stored in different tables. So that it will be easier to retrieve the date when needed. The most common database used with php is Mysql. Mysql is a relational database. A relational database is one in which tables are linked together.

What is a Table?
A table is an structure in which the datat is stored, It can contain rows and columns. Columns are used to categorize the data and rows contain the actual data. For example if a company contains its user's data in a table named 'Users' then the table structure may look like this:


User Id User Name Email Password
1 John john@example.com 123
2 Smith smith@example.com 456

In the above example, A company's users table is shown, it contains 4 columns and 2 rows. 4 columns are the categories and 2 rows are actual data. It is not mandatory that each row contains all the columns, some times rows can contain empty columns.

What is a Query?
A query is an statement used to manipulate the data in the database. You can write queries to Insert, retrieve, delete, and update the data and also to perform any action on the data present in the database.A sample query may look like this:
SELECT email FROM users
The above statement is used to retrieve all the emails from the users table. So the output of the above query will be like this:

Email
john@example.com
smith@example.com

Well I guess that's all for the introduction, further details will be discussed in the later lessons. For any queries or questions should you have, feel free to comment.

next Previous Lesson --- Next Lesson next

14 May 2011

How to check a file exists on server using php

Sometimes we need to check whether a file or directory exists on server or not, well this can be done by a built-in php function "file_exixts". This function takes the path of the file as argument and check on the server for file, if the file exists on server it returns true and if it is not then it returns false. The syntax and example usage of this function is stated below:

Syntax
bool file_exists ( string $filename )
Example usage
<?php
$file1="example.php";
if (file_exists($file1))
        echo $file1." exists on the server";
else
    echo $file1." does not exist on the server";
?>
You can test this example by placing a file named "example.php" in the same directory as the file containing the example code.

Reference
http://php.net/manual/en/function.file-exists.php

For any queries and issues should you have, please feel free to comment and ask.

10 May 2011

301 redirect non www urls to www using htaccess

In the search engine optimization url canonicalization issues are very common. What is url caonicalization? Basically url canonicalization means that two or more of your urls are having duplicate content. An example of such urls is as follows:


http://example.com
http://www.example.com

Both of the above mentioned urls will have the same content therefore canonicalizing each other. To resolve this issue we 301 redirect one of the url to other. Mostly we 301 redirect non www url to the one with www.

This can be done simply by adding the following code in the .htaccess file:


###########FOR example.com to www.example.com###########
RewriteEngine on
Rewritecond %{http_host} ^example.com [nc]
Rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
#########################################################

For any queries or questions, feel free to comment.