Pages

Monday, December 16, 2013

Fix Cannot modify header information - headers already sent error


  1. Remove any blank line present. There should not be any line gaps between the code of lines.

Monday, October 21, 2013

PHP abstract classes

  • Abstract classes cannot be instantiated
  • A class must be declared as abstract if any of its method is abstract
  • Methods defined as abstract must only declare its signature
  • When inheriting from abstract class the child must define all the abstract methods with the same visibility or lower
  • The type and arguments must match the signature

Installing Zend Framework 2 Skeleton Application in Ubuntu

  1. Go to https://github.com/zendframework/ZendSkeletonApplication and click the “Zip” button
  2. This will download a file with a name like ZendSkeletonApplication-master.zip
  3. Unzip this file into the directory and rename it to something like 'skeleton'
  4. Navigate into this folder and run the composer.phar as described below
  5. 
    cd skeleton
    php composer.phar self-update
    php composer.phar install
    
    
  6. This installs ZF2 in the vendor/zendframework/zendframework folder

Friday, October 11, 2013

Enabling clean url via .htaccess in drupal 7

Sometimes due to server settings the clean url test may fail. To fix this make sure to add the below lines in .htacess file in the drupal root folder.


# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ /client/delacon/devel/index.php [L]

Thursday, October 3, 2013

Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed'

You have to cast the XML data to a string because internally they are all SimpleXMLElement


$event['mov'][$y]['name'] = (string)$child->name;
$event['mov'][$y]['movie_id'] = (string)$child->venues->venue->attributes()->id;
$event['mov'][$y]['description'] = (string)$child->description;

Wednesday, September 25, 2013

Monday, September 16, 2013

Diff files and directories in linux/ubuntu


diff -bur folder1/ folder2/

This will output a recursive diff that ignore spaces, with a unified context.

Wednesday, August 21, 2013

Moving files from local server to production server in magento

  1. Change the values in core_config_data table from http://localhost/project_name/ to http://project_name/ for both web/unsecure/base_url and web/secure/base_url
  2. Update the /app/etc/local.xml file as below:


<host><!--[CDATA[localhost]]--></host>
<username><!--[CDATA[{your_db_username}]]--></username>
<password><!--[CDATA[{your_db_password}]]--></password>
<dbname><!--[CDATA[{your_db_name}]]--></dbname>

// {write these values without quotes}



Monday, August 5, 2013

How to make a custom email template from the webform form component fields in drupal 7

Example: In the email settings in webform, in the email template enter the below code.

Dear %value[first_name],  // where first_name is the field key of the component

Thank you for subscribing our newsletter. Your email address has been added to our mailing list.

The details of your submissions are:
%email_values

Monday, July 15, 2013

Not able to create directory in ubuntu due to file permissions


  1. Check if logged in as admin or user and not as guest
  2. Only after logging in as root user, you will be able to use sudo and nautilus to change the file permissions

Wednesday, June 12, 2013

Enable .htaccess file - to fix zend controller path not being recognized

To make .htaccess files work as expected, you need to edit this file:

/etc/apache2/sites-available/default

Look for a section that looks like this:


<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>


You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it's okay to allow .htaccess files to over-ride previous directives. You must reload Apache before this change will have an effect:

sudo /etc/init.d/apache2 reload

Thursday, June 6, 2013

Fix localhost error prompting for phtml file download in ubuntu

Ignore the 1st two lines if apache and php is already installed and working fine.

sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart

Wednesday, May 29, 2013

Find if variable exists or defined in javascript

For example

if(typeof selected_val === 'undefined')
{
 alert('Variable selected_val does not exist');
}

Changing password in phpmyadmin ubuntu 12.04

In the ubuntu console type the following one by one

sudo /etc/init.d/mysql stop
sudo mysqld_safe --skip-grant-tables &
mysql -u root
use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
flush privileges;
quit

Reset Mozilla Firefox

  1. Under the main menu click on Help -> Troubleshooting Information
  2. At the right side there will be a box to reset firefox
  3. Click on 'Reset Firefox...' button
  4. Firefox will now be restored to its default initial state

Monday, May 20, 2013

Set path to run java code in windows xp command line

Type the following code in the console

set path=%path%;C:\j2sdk1.4.2_04\bin;.;

where C:\j2sdk1.4.2_04\bin - represents the javac directory and the ending dot represents the current directory where file is stored.

Parse error in codeigniter on wamp

Change the value of the following line in \application\config\config.php from FALSE to TRUE.

$config['rewrite_short_tags'] = TRUE;

And in the wamp php.ini file

short_open_tag = On

This can be found under the heading

;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;

Tuesday, April 30, 2013

Jquery text repeat when used with on click and append

For example:

<script  type="text/javascript">
jQuery(
  function($)
  {
    $('div')
      .click(function(e)
             {
              $('span',this).append('A');
             }
            );
  }
);
</script>
<div><div><b>click here:</b><span></span></div></div>


If you click on the text, the click will trigger on the inner div and bubble up to the outer div, the function will be executed 2 times.
To avoid this use stopPropagation()

<script  type="text/javascript">
jQuery(
  function($)
  {
    $('div')
      .click(function(e)
             {
              e.stopPropagation();
              $('span',this).append('A');
             }
            );
  }
);
</script>
<div><div><b>click here:</b><span></span></div></div>


Saturday, March 30, 2013

Remove extra space in dreamweaver

  1. Open the file
  2. Click CTRL + F
  3. Tick "Use regular expression"
  4. Type  the following in "Find"
  5. 
    [\r\n]{2,}
    
    
  6. Type  the following in "Replace"
  7. 
    \n
    
  8. Press "Replace All"

Monday, March 25, 2013

Add Scrolbar only if content present

If you have an element whose content has to scroll only when it exceeds a particular width/height you can do so by assigning an id or class with the following css properties so that the scrollbar will appear only if the height exceeds the threshold value.

.noscroll {
  width:150px;
  height:150px;
  overflow: auto; 
}

Tuesday, March 5, 2013

Check the executable version in ubuntu linux

Enter the following command in the terminal

file [file_name]

Thursday, February 28, 2013

Find local ip address in ubuntu

  1. Click on connections icon and select Connection Information
  2. The ip address will be displayed there

Saturday, February 16, 2013

Disable Windows Update

  1. Click on Start
  2. Search for Windows Update(You can type this in the Search programs and files field)
  3. Click on Change settings
  4. Select 'Never check for updates'
  5. Click Ok

Disable Java Auto Uploader

  1. Navigate to where Java is installed
    Example:
    
    C:\Program Files (x86)\Java\jre[version]\bin\javacpl.exe
    
    
  2. Then scroll down till you see:
    
    javacpl.exe
    
    
  3. Right click on it, and click Properties
  4. Click on the Compatability Tab
  5. Check the Run this Program as an Administrator
  6. Click Apply, then click Ok
  7. Now double click javacpl.exe
  8. Click on Yes
  9. Under Update tab, uncheck 'Check for updates automatically'
  10. Click on Apply and  then Ok

Friday, January 25, 2013

Reinstall custom module in magento


  1. Delete the appropriate table name in core_resource db table
  2. Delete the module table

Wednesday, January 23, 2013

Add a glow around textarea on focus in html forms

In the css file, add the following lines:

textarea{border: 1px solid #ccc;}
textarea:focus{box-shadow: 0 0 8px rgba(82,168,236,.5); border: 1px solid rgba(82, 168, 236, .75);}

Couldn't resolve host 'magento-community'

Use this in front of the extension key name:

http://connect20.magentocommerce.com/community/

Example:


http://connect20.magentocommerce.com/community/banner 

Wednesday, January 16, 2013

Writing to downloadable file in PHP


$text_to_write = 'Example text to be written to file';
$fwrt = fopen($path.'file.txt', 'w');
fwrite($fwrt,$text_to_write);
fclose($fwrt);
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="example.txt"');
readfile($path.'file.txt');
exit();    // if this line is not included entire page code will also be written into the file