Category: PHP

In our PHP session you will learn about PHP, and how to execute scripts on your application

Execute PHP Script from command line in Ubuntu

Some times there is a great requirement to execute some codes of PHP immediately, but for that we have to format the output according to HTML format since generally PHP scripts are executed using LAMP. For example if we want to fetch some data from a table of RDB using PHP and need to see …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/01/execute-php-script-from-command-line-in-ubuntu/

Enable curl for PHP

We come across web applications which are written in PHP and require curl extension. PHP curl functions can used through use of libcurl. The libcurl was create by Daniel Sternberg. With the help of libcurl you can connect and communicate with webserver using different protocols. cURL stands for Client for URLs. It allows us to …

Continue reading

Permanent link to this article: https://blog.openshell.in/2011/01/enable-curl-for-php/

PHP Pagination Script

In this article, attached the script to make it working and easy to edit. This is a flexible and easy to implement PHP pagination script which will help you split large result sets over multiple pages. Click here to download the script Steps to use: include the ps_pagination.php file to your script. Create a ps_pagination …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/php-pagination-script/

MySQL Subquery Optimization

Never use a subquery inside a WHERE field IN(…)  the SQL query.  It will slow down the process. Slow: SELECT * FORM table1 WHERE field1 IN (SELECT field2 FROM table2 GROUP BY field1) Instead of using a subquery inside an IN(…),  use INNER JOIN query. It will speed up the process, but in IN(…) query …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/mysql-subquery-optimization/

Enable .htaccess in Apache2

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 …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/enable-htaccess-in-apache2/

How to avoid Conflict in jQuery

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery’s case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/how-to-avoid-conflict-in-jquery/

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. …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/404-page-on-a-static-site/

Tips for using jQuery

Find if something is hidden: We use .hide(), .show() methods in jquery to change the visibility of an element. Use following code to check the whether an element is visible or not. if($(element).is(“:visible”) == “true”) { //The element is Visible } Center an element on the Screen: To make align the element to center. jQuery.fn.center …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/tips-for-using-jquery/

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, …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/escape-string-literals-for-sql/

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 …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/12/quoting-html-attribute-values/