How to increase or decrease the maximum execution time of a php script

By default PHP script execution time is set for 30 seconds at php.ini file. This is the time limit set for all the files to finish its execution. If the file takes more than this set time then the execution of the script will be stopped and error message will be displayed like this.

Fatal error: Maximum execution time of 30 seconds exceeded in F:php_filesttest.php on line 14

This maximum execution time limit is set inside the php.ini file like this.

max_execution_time = 30 ; Maximum execution time of each script, in seconds

This value can be increased or decreased as per our requirement at php.ini file but note that in a server environment where many sites are hosted, any change in php.ini will affect all the sites hosted by the server. So this change is not possible unless you own the server and you are the only user. In a shared hosting our host may not like to change any settings of php.ini for our requirement. So there is a option to set the file execution time for the particular file at the individual file end. This adjustment of time limit has no effect if php is running in safe mode. Let us try to learn how this works.

Setting page titles and meta tags in cakephp 2.0

Today I needed to have page titles and meta tags correctly setup for each page in a website i had often used methods like placing variables and setting them to the template in the app controller in a beforeFilter. Then if i needed a different meta tag on another page like contact for example i could go to the contact controller and and overwrite these variables. A great idea but didn’t work too well for the simple pages and the pages controller.

Here is Idea how you can add page titles and meta tags easy in your cake pages

1- First we need to set the page tile,place this code within your method on the controller :
$this->set(“title_for_layout”,”your page title goes here”);

2- Second add below code to your respective view page :

echo $this->Html->meta(‘keywords’, ‘your keywords goes here’, array(‘type’ => ‘keywords’, ‘inline’ => false));
echo $this->Html->meta(‘description’, ‘your description goes here’, array(‘type’ => ‘description’, ‘inline’ => false));

Hope this will help!!!!!!!!!!

Login issue with admin, user and unable to register in oscommerce

Recently we have an issue with oscommerce. We were developing an oscommerce site and everything was working fine in our test server. But when we moved to the production server provided by the client it stops working.

The issue was we couldn’t login as admin. Every time we logged in with correct parameters it was showing an error “Error: Invalid administrator login attempt.” We were searching for a solution in the google but nothing helped us. Later we found that we cannot even login as users and cannot register a new user also. So we have done some debugging and atlast what we got the solution.

The issue with the domain name and the one which we gave in the configure.php. The domain name always show with www. ie, when we type http://mysitename.com it will show as http://www.mysitename.com. What we gave in our configure.php file was http://mysitename.com. So issue with generating cookie and also POST information. When we changed the value of configure.php from http://mysitename.com to http://www.mysitename.com, it began to work. Hope it will be helpful for some others also.

How to Increase PHP’s File Upload Limit Using php.ini

The file upload size limit 2M(Approx) is set by shared hosting providers. They have set it low because it save bandwidth, keep the server moving quickly.
But customers really need a large upload limit? So we must increase the file upload size limit. We can do it by 4 way :

1- By adding below code on the page where you have upload function

ini_set(‘memory_limit’, ‘256M’); //needs to be in {x}M format
ini_set(‘upload_max_filesize’, ’50M’); //needs to be in {x}M format
ini_set(‘post_max_size’, ’50M’); //needs to be in {x}M format

2- Using below code in php.ini file

memory_limit = 256M
upload_max_filesize = 50M
post_max_size = 50M

Make php.ini file and upload it on the root folder

3- Using .htaccess file (Add below code in this file)

php_value memory_limit 256M
php_value upload_max_filesize 50M
php_value post_max_size 50M

4- Finally if above 3 tricks not work, then you need to contact to your hosting provider.

Quick Setup Guide To Run CakePHP 2.0 On Windows 7

In this tutorial, I will show you, how to set and run the CakePHP 2.0 framework on Windows 7. For those who have not heard of CakePHP before, it is an open source web application framework for producing web applications. It is written in PHP, modeled after the concepts of Ruby on Rails, and distributed under the MIT License. CakePHP is licensed under the MIT license which makes it perfect for use in commercial applications and comes with built-in tools for input validation, CSRF protection, Form tampering protection, SQL injection prevention, and XSS prevention, helping you keep your application safe & secure.

You can get more information on cakephp official site cakephp.org

Below proceeding you must know about cakephp system requirements:

HTTP Server. (Recommended Xampp Or Wamp)
For example: Apache. mod_rewrite is preferred, but by no means required.
PHP 5.2.8 or greater.
Technically a database engine isn’t required, but we imagine that most applications will utilize one. CakePHP supports a variety of database storage engines:

MySQL (4 or greater)
PostgreSQL
Microsoft SQL Server
SQLite

Downloading CakePHP

To download the latest major release of CakePHP. Visit the main website http://www.cakephp.org and follow the “Download Now” link.

All current releases of CakePHP are hosted on Github. Github houses both CakePHP itself as well as many other plugins for CakePHP. The CakePHP releases are available at Github downloads.

Now below are the steps you need to follow :

1-Once the download completed, extract the files and copy the files into the web server www root. You should place the folder as the same name. The folder’s name can be changed as you wished and doesn’t required to be named as cake in order to run it. Do not start the server yet , there are some configuration needed to be done on the Apache core files before running the CakePHP framework.

2- You must enable rewrite module on the apache. If it is already enabled then no need to take this step. Here is the steps how you can enable rewrite module :

Find the code below in the httpd.conf file and uncomment it. This is to enable the rewrite module on the apache. By default it is turned off in some web servers. If it is already uncommented you can continue to the next step.

Locate this code and remove the ‘#’ which is located in front of the line.
#LoadModule rewrite_module modules/mod_rewrite.so
The modified code should look like this. Save and close the file, upon completing the modification
LoadModule rewrite_module modules/mod_rewrite.so

3-Now, start your server and visit the location of the folder via your preferred Internet Browser. Eg. http://localhost/cake/.

That’s all!!

WordPress issue : Could not create upgrade directory

Today I got strange issue while update wordpress site. This gave me error like this “Could not create upgrade directory”.

Firstly I thought this was the issue of directory permission so I did set upgrade directory 777 mode but I was unsuccessful. Then tried to delete upgrade folder and created new one, for me that was still issue. Then I read the some articles on WordPress codex and this trick(delete and create upgrade directory) works for many people. But in the mine case this was not work. I started think about this issue and found the issue with ask apache module. This module was not giving permission to write anything on the directory.

Finally I deactivate ask apache module and upgrade my WordPress version as well as plugin and again I activated this plugin for security purposes. This technique worked for me very well.

Hope this method will work for other people.

Increase PHP’s File Upload Limit Using .htaccess file

How do we increase upload file limit through .htaccess file. Here I am giving you quick trick.

Create .htaccess file(If you have already .htaccess file on the server then no need to create it just update that file) using your favorite text editor like notepad++ and put below code on that file :

php_value memory_limit 256M
php_value upload_max_filesize 50M
php_value post_max_size 50M

If you want to also increase the php script execution time then put this code in the .htaccess file

php_value max_execution_time 18000

The values 256M,50M and 18000 you can change as per your requirement.

How to include JQuery on your WordPress theme

WordPress comes with JQuery (It is used in the dashboard) so you don’t need to download a new copy of JQuery to your WordPress server.
For accessing JQuery on WordPress site, you need to paste below code on your header.php file within the and tags:

When you will add this JQuery automatically will be called in the website.

That’s all!!

Javascript Confirm Delete

How to use a javascript confirm box to ask the user if they want to delete

<script>
function confirmDelete(deleleteUrl) {
if (confirm(“Are you sure you want to delete”)) {
document.location = deleleteUrl;
}
}
</script>

<a href=”javascript:confirmDelete(‘delete.php?id=1’)”>Delete</a>

Another way

<a href=”delete.php?id=1″ onclick=”return confirm(‘Are you sure you want to delete?’)”>Delete</a>

How to add .SWF files to the html webpage

Here I am sharing flash code for embedding flash in the website. Hope this will help many more….

<object width=”400″ height=”220″ align=”middle” classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″ codebase=”http://fpdownload.macromedia.com/pub/shockwave/cabs
/flash/swflash.cab#version=7,0,0,0″ id=”player1″>
<param value=”your_flash_file.swf” name=”movie”>
<param name=”menu” value=”false”>
<param name=”quality” value=”high”>
<param name=”wmode” value=”transparent”>
<param name=”bgcolor” value=”#FFFFFF”>
<embed width=”400″ height=”220″ align=”middle” src=”your_flash_file.swf” menu=”false” quality=”high” bgcolor=”#FFFFFF” name=”player” wmode=”transparent” allowtransparency=”true” allowscriptaccess=”always” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer”>
</object>

If you want to change any attribute then you can take reference from adobe site. Here is the link :

Flash OBJECT and EMBED tag attributes