At first You should define, mod_rewrite is a part of Apache server that can rewrite requested urls on the fly. To enable in Ubuntu, you just need to write this command in terminal sudo a2enmod rewrite Then edit /etc/apache2/sites-available/default Find the following Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all and change …
Tag: PHP
Permanent link to this article: https://blog.openshell.in/2010/12/enable-htaccess-in-apache2/
Dec 13
404 Page on a Static Site
Here’s a very quick, but very useful trick. You can catch 404 errors (page not found) on a static site and serve up a custom 404 page with a one-liner in your .htaccess file: ErrorDocument 404 /404.php The “/404.php” part is the path to whatever file you want to serve up as the error page. …
Permanent link to this article: https://blog.openshell.in/2010/12/404-page-on-a-static-site/
Dec 02
Escape String Literals for SQL
To run a SQL query with text data containing single quotes ‘ as well as other SQL reserved punctuations, and to prevent SQL injections, you will always want to escape the text values before using them in a SQL query. mysql_real_escape_string() calls MySQL’s library function mysql_real_escape_string, which prepends backslashes to the following characters: x00, n, …
Permanent link to this article: https://blog.openshell.in/2010/12/escape-string-literals-for-sql/
Dec 01
Quoting HTML attribute values
The values of attributes can contain text, hexadecimal color codes or numbers. In case of JavaScript event handlers, the values consist of small JavaScript code. A sincere advice for good and clean HTML coding is to always put quotes around attribute values. It is a good habit, will save you many headaches and avoid errors …
Permanent link to this article: https://blog.openshell.in/2010/12/quoting-html-attribute-values/
Dec 01
HTML mailto attribute
The HTML mailto is a quick way to add the facility of receiving feedback from visitor on the web site. when the visitor clicked the HTML mailto, It lanuches their email program with new email window. Note: HTML mailto assumes that the visitor has configured an email client (Outlook Express, Netscape Messenger, Thunderbird or any …
Permanent link to this article: https://blog.openshell.in/2010/12/html-mailto-attribute/
Nov 24
Find out IP address
We can get the IP address of any visitor by using PHP. Finding the IP address is very important requirement for many scripts where we store the members or visitors details. For security reason we can store IP address of our visitors who are doing any purchases or recording the geographical location of the visitor …
Permanent link to this article: https://blog.openshell.in/2010/11/find-out-ip-address/
Nov 23
Send HTML Mail With PHP
Sending html email in php is extremely easy. All you have to do is call the “mail” function with some extra header. Have a look on example: <?php //define the receiver of the email $to = ‘youraddress@example.com’; //define the subject of the email $subject = ‘Test HTML email’; //create a boundary string. It must be unique //so …
Permanent link to this article: https://blog.openshell.in/2010/11/send-html-mail-with-php/
Nov 23
Single quotes, Double quotes
It’s easy to just use double quotes when concatenating strings because it parses everything neatly without having to deal with escaping characters and using dot values. However, using single quotes has considerable performance gains, as it requires less processing. For Example: <?php //Consider this string $howdy = ‘everyone’; $foo = ‘hello $howdy’; $bar = “hello $howdy”; // Concatenating this strings $howdy = ‘everyone’; …
Permanent link to this article: https://blog.openshell.in/2010/11/single-quotes-double-quotes/
Nov 23
Scripts Execution Time Limits
Putting a time limit on your PHP scripts is a very critical thing. There are times when your scripts will fail, and when they do, you’ll want to use the set_time_limit function to avoid infinite loops and database connection timeouts. The set_time_limit puts a time limit on the maximum number of seconds a script will …
Permanent link to this article: https://blog.openshell.in/2010/11/scripts-execution-time-limits/
Nov 23
Increase PHP Script Execution Time Limit
Every once in a while we need to process a HUGE file. Though PHP probably isn’t the most efficient way of processing the file, we usually use PHP because it makes coding the processing script much faster. To prevent the script from timing out, I need to increase the execution time of the specific processing …
Permanent link to this article: https://blog.openshell.in/2010/11/increase-php-script-execution-time-limit/