Wednesday, October 20, 2010

Page Loading Screen/Image for all pages Simple HTML

Use this image or image of your own choice Try some animated gif's for rich UI experience



and this HTML

<!-- Display a loading image while the page is loading Author: Hariharan.C-->
<html>
<head>
<meta equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#loadingDiv img{ border: none; }
#loadingDiv{ opacity: 0.8;filter: alpha(opacity = 80); ZOOM: 1}
/** For IE6 enable this

* html #loadingDiv{
background-color: transparent;
background-image: url(blank.gif);
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="overlay.png", sizingMethod="scale");

}*/
</style>
</head>
<body onload="init()">
<div id="loadingDiv" style="position:absolute;width:100%;height:100%;background-color:#777777;display: block; top: 0pt; left: 0pt; "><div style="z-index: 90;position: absolute; z-index: 150; top: 248px; left: 610px;text-align:center"><img src="loading.gif" id="loadingImage" /><br />Loading Page...Please wait</div></div>
<script type="text/javascript">
var loadingDivObj=(document.all);
var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
if (ns4)
loadingDivObj=document.loadingDiv;
else if (ns6)
loadingDivObj=document.getElementById("loadingDiv").style;
else if (ie4)
loadingDivObj=document.all.loadingDiv.style;
function init()
{
if(ns4){loadingDivObj.visibility="hidden";}
else if (ns6||ie4) loadingDivObj.display="none";
}
</script>

<!-- Write your HTML Here -->
<!-- Sample HTML -->
<iframe src="http://www.google.com" style="width:auto;height:auto"></iframe>
</body>
</html>


Use this code to display a page loading screen/image. Place the code in the top of the page before loading css/javascript.

Tuesday, October 19, 2010

Learn how to Install Apache, PHP, MySQL and phpMyAdmin

Apache Logo PHP Logo MySQL Logo phpMyAdmin Logo

Learn how to Install Apache, PHP, MySQL and phpMyAdmin:

This tutorial will show you step-by-step how to install:
  • Apache 2
  • PHP 5
  • MySQL 5
  • phpMyAdmin
The Apache Server combined with the power of PHP, MySQL, and phpMyAdmin, creates one of the best possible development environments for a web programmer. Getting everything properly configured can take 20-30 minutes, so make sure you have enough time set aside before beginning the installation.

Don't be intimidated by the length of this page. I'll walk you step-by-step through each part of the installaton. All you need is a basic understanding of HTML and computers, and if any part of the installation isn't clear to you, just send me an email.

Start the Installation:

    Installing Apache:

    Today we will be installing Apache version 2.2.4. Follow the steps carefully.
    1. Go to www.apache.org and download "Win32 Binary (MSI Installer): apache_2.2.4-win32-x86-no_ssl.msi" to your desktop.

      Note: Make sure that you download Apache version 2.2.4 (Win32 Binary MSI Installer)! The rest of the tutorial is written using this version.

    2. Double click "apache_2.2.4-win32-x86-no_ssl.msi", and if prompted, click "run".

    3. An installation wizard will appear:

      Start the Apache Server Installation

      Click "Next".

    4. The next page contains the terms of agreement. Select "I accept", and click "Next".

    5. Read about the Apache Server, and click "Next"

    6. The next screen will ask you for specific server information. Enter the values seen below:

      Configure Apache

      Click "Next".

    7. On the next screen, select "Typical Installation" and click "Next".

    8. Click "Next".

    9. Click "Install".

    10. Open up Internet Explorer and type in "http://localhost". If you see a page that says "It works!" then the Apache server has been installed successfully.

      Apache Server Success Page

    A few notes on your Apache Server Configuration:
    • Apache is installed by default in your "C:\Program Files\Apache Software Foundation\Apache2.2" directory.
    • Inside that directory there is a folder called "htdocs" (the equivilant of your \www\ or \public_html\ directory). You can develop your applications inside this folder and access them by going to http://localhost/your_file_name.php
    • The Apache Configuration settings are defined in a file named "httpd.conf" located in the "conf" directory. Do not attempt to change these settings unless you know what you're doing. An error in this file will result in the Apache Server not functioning correctly!

    Installing PHP:

    Next we will be installing PHP version 5. Follow the steps carefully.
    1. Go to www.php.net and download the "PHP 5.2.0 zip package" to your desktop. (Be patient while it downloads, the ZIP file is over 9MB!)

      Note: Make sure that you download the PHP 5.2.0 zip package! The rest of the tutorial is written using this version.

    2. Create a new folder called "php" in your C Drive. Copy the "php-5.2.0-Win32.zip" file to there ("C:\php") and extract it using WinZIP or a similiar program.

    3. Your "C:\php" directory should now look like:

      PHP Directory

    4. Next copy the "php.ini-dist" file from "C:/php/" to "C:/WINDOWS" and rename it to "php.ini". This is your PHP configuration file. We'll come back to this later.

    5. Now it's time to tell Apache that PHP exists. Open up your Apache configuration file ("C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf") in notepad and add these four lines to the bottom of the "LoadModule" section:

      LoadModule php5_module "c:/php/php5apache2_2.dll"
      AddHandler application/x-httpd-php .php
      # configure the path to php.ini
      PHPIniDir "c:/windows"

    6. In your "htdocs" directory, create a file called "info.php". Open it in notepad and add this line of code to it:

      <?php phpinfo(); ?>

    7. Restart your Apache Server for the changes to take effect: Start > All Programs > Apache HTTP Server 4.2.4 > Control Apache Server > Restart

    8. Open up Internet Explorer and type in: http://localhost/info.php. If your browser takes you to a page that looks like this, then PHP has been installed successfully!

      PHP Info Page

    Modifying your PHP Configuration File:
    • Your PHP configuration (php.ini) file is located in "C:/WINDOWS/php.ini". You can modify it with notepad or a similiar text editor.
    • Open it up and find the line that says:

      extension_dir = "./"

      and change it to

      extension_dir = "C:\php\ext"

    • Find the line that says:

      ;session.save_path = "/tmp"

      and change it to

      session.save_path = "C:\WINDOWS\temp"


    Installing MYSQL:

    Next we will be installing MySQL version 5. Follow the steps carefully.
    1. Go to www.mysql.com and download the "Windows (x86) ZIP/Setup.EXE (version 5.0.27)" to your desktop. (To do this you'll need to register an account with MySQL.)

    2. Once "mysql-5.0.27-win32.zip" has finished downloading, you can extract it using WinZIP or a similiar program.

    3. Once extracted, double click on the "Setup.exe" file. An installation wizard will appear.

      Start the MySQL Server Installation

      Click "Next".

    4. Select "Typical" Installation and click "Next".

    5. Click "Install". (Be patient, this can take up to several minutes).

    6. The next screen will ask you to "Sign Up". Select "Skip Sign-Up" for now.

    7. The next screen will tell you that the installation wizard is complete. Make sure that the "Configure the MySQL Server now" field is checked before clicking "Finish".

      Create a MySQL Server Instance

    8. The MySQL Server Instance Configuration Wizard should appear. Click "Next".

    9. Select "Detailed Configuration" and click "Next".

    10. Select "Developer Machine" and click "Next".

    11. Select "Multifunctional Database" and click "Next".

    12. Click "Next".

    13. Select "Decision Support (DSS)/OLAP" and click "Next".

    14. Select "Multifunctional Database" and click "Next".

    15. Make sure "Enable TCP/IP Networking" is checked, the Port Number is set to "3306", and "Enable Strict Mode" is checked. Click "Next".

    16. Select "Standard Character Set" and click "Next".

    17. Check "Install As Windows Service", set the Service Name to "MySQL", and check "Launch the MySQL Server automatically". Make sure that the "Include Bin Directory in Windows Path" is NOT checked. Click "Next".

    18. On the next screen, check the box that says "Modify Security Settings". Enter a password for the default "root" account, and confirm the password in the box below. Do NOT check the boxes "Enable root access from remote machines" or "Create An Anonymous Account". Click "Next".

    19. Click "Execute". (This may take a few minutes. Be patient).

    20. Click "Finish".

    21. To test if MySQL was installed correct, go to: Start > All Programs > MySQL > MySQL Server 5.0 > MySQL Command Line Client. The MySQL Command Line Client will appear:

      MySQL Command Line

    22. It will ask you for a password. Enter the password you created in step 18. (If you enter an incorrect password MySQL will automatically close the command line)

    23. Next, type in the commands shown below: (shown in blue)

      Test MySQL

      If you don't get any errors, and it returns the information shown above, then MySQL has been successfully installed! Next we will need to configure PHP to work with MySQL.

    Configuring PHP to work with MySQL:

    Now that both PHP and MySQL are installed, we have to configure them to work together.
    1. Open up your php.ini file (C:/WINDOWS/php.ini) and find the line:

      ;extension=php_mysql.dll
      To enable the MySQL extension, delete the semi-colon at the beginning of that line.

    2. Next we must add the PHP directory to the Windows PATH. To do this, click: Start > My Computer > Properties > Advanced > Environment Variables. Under the second list (System Variables), there will be a variable called "Path". Select it and click "Edit". Add ";C:\php" to the very end of the string and click "OK".

    3. Restart your computer for the changes to take effect.

    4. Create a new file in your "htdocs" directory called "mysql_test.php".

    5. Copy the following code into "mysql_test.php" and click save. (Make sure to replace the MYSQL_PASS constant with the MySQL Password you specified during the MySQL installation).

      <?php

      # Define MySQL Settings
      define("MYSQL_HOST", "localhost");
      define("MYSQL_USER", "root");
      define("MYSQL_PASS", "password");
      define("MYSQL_DB", "test");

      $conn = mysql_connect("".MYSQL_HOST."", "".MYSQL_USER."", "".MYSQL_PASS."") or die(mysql_error());
      mysql_select_db("".MYSQL_DB."",$conn) or die(mysql_error());

      $sql = "SELECT * FROM test";
      $res = mysql_query($sql);

      while ($field = mysql_fetch_array($res))
      {
      $id = $field['id'];
      $name = $field['name'];

      echo 'ID: ' . $field['id'] . '<br />';
      echo 'Name: ' . $field['name'] . '<br /><br />';
      }

      ?>
    6. Open up Internet Explorer and type in "http://localhost/mysql_test.php". If the "mysql_test.php" page returns something similiar to:

      ID: 1
      Name: John

      Then PHP & MySQL have been successfully configured to work together. Congratulations! The next and final step is to install phpMyAdmin.


    Installing phpMyAdmin:

    Now that both Apache, PHP and MySQL are installed, we can install phpMyAdmin, a tool that allows you to easily manage your MySQL databases.
    1. Go to www.phpMyAdmin.net and download "english.zip" under the phpMyAdmin 2.9.2 section to your desktop (I assume that since you are reading this article that you understand English).

    2. Create a new folder called "phpmyadmin" in your "htdocs" directory. Extract the contents of the "phpMyAdmin-2.9.2-english.zip" ZIP file here. Your C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmyadmin" directory should now look like:



    3. Create a new file in the "phpMyAdmin" directory (above) called "config.inc.php". Place this code inside it and be sure to replace "YOUR_PASSWORD_HERE" (in both places below) with your MySQL Password:

      <?php

      /* $Id: config.sample.inc.php 9675 2006-11-03 09:06:06Z nijel $ */
      // vim: expandtab sw=4 ts=4 sts=4:

      /**
      * phpMyAdmin sample configuration, you can use it as base for
      * manual configuration. For easier setup you can use scripts/setup.php
      *
      * All directives are explained in Documentation.html and on phpMyAdmin
      * wiki <http://wiki.cihar.com>.
      */

      /*
      * This is needed for cookie based authentication to encrypt password in
      * cookie
      */
      $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

      /*
      * Servers configuration
      */
      $i = 0;

      /*
      * First server
      */
      $i++;

      $cfg['Servers'][$i]['user'] = 'root';
      $cfg['Servers'][$i]['password'] = 'YOUR_PASSWORD_HERE'; // Your MySQL Password


      /* Authentication type */
      $cfg['Servers'][$i]['auth_type'] = 'config';
      /* Server parameters */
      $cfg['Servers'][$i]['host'] = 'localhost';
      $cfg['Servers'][$i]['connect_type'] = 'tcp';
      $cfg['Servers'][$i]['compress'] = false;
      /* Select mysqli if your server has it */
      $cfg['Servers'][$i]['extension'] = 'mysql';
      /* User for advanced features */
      $cfg['Servers'][$i]['controluser'] = 'root';
      $cfg['Servers'][$i]['controlpass'] = 'YOUR_PASSWORD_HERE'; // Your MySQL Password
      /* Advanced phpMyAdmin features */
      $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
      $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
      $cfg['Servers'][$i]['relation'] = 'pma_relation';
      $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
      $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
      $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
      $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
      $cfg['Servers'][$i]['history'] = 'pma_history';

      /*
      * End of servers configuration
      */

      /*
      * Directories for saving/loading files from server
      */
      $cfg['UploadDir'] = '';
      $cfg['SaveDir'] = '';

      ?>


    4. phpMyAdmin has now been successfully installed! To use it, open up Internet Explorer and type in "http://localhost/phpmyadmin". This will bring you to the main phpMyAdmin page. If you have any questions, refer to the phpMyAdmin website or the "Documentation.html" file in the /phpMyAdmin/ directory.
    5. Enjoy using Apache, PHP, MySQL, and phpMyAdmin!

    Monday, September 27, 2010

    Make your own Lightbox using jquery

    Here is the easy way to create your own light box using jquery in a simple way

    Html:
    Create any button for triggering the function
    For example
    input type="button" name="test" onclick="myLightbox()"

    Here is the CSS for the overlay container

    #popup-overlay {
    height:100%;
    left:0;
    position:absolute;
    top:0;
    width:100%;
    z-index:5;
    background:#777777;
    opacity: 0.8;filter: alpha(opacity = 80); ZOOM: 1
    }
    #my-div {

    left:100px;
    position:absolute;
    top:50px;
           z-index:15;

    }

    Here is the script to enable the lightbox


    function myLightbox(){
    scrollbar("hide");
    $("body").append('<div id="popup-overlay"></div>');
         $("body").append('<div id="my-div"><input type="button" name="close" onclick="closeLightbox()" /></div>');
    window.location.href= "#";
    }


    function closeLightbox(){
    scrollbar("show");
    $("#my-div").remove();
    $("#popup-overlay").remove();
    }


    function scrollbar(action){
        if(action == "show"){
    $("html") .css('overflow',''); 
    //if previous statement is not working use the following
    //        document.body.scroll = "";
      //      document.body.style.overflow = "";       
        }
        else {
    $("html") .css('overflow','hidden');
    //if previous statement is not working use the following 

          //  var oTop = document.body.scrollTop;
           // document.body.style.overflow = "hidden";
           // document.body.scrollTop = oTop;   
        }
    }

    Note: For this you need to load the jquery file.

    Sunday, September 26, 2010

    Rotate Div or Image using Jquery (IE and Firefox Tested)

    Rotate Div or Image using Jquery (IE and Firefox Tested


    Here is the Html image tag for which one you want to rotate 90 degeree, 180 degree, etc. This rotating is clock wise direction. you can make this as a anticlock wise direction too

    img src="test.jgp" id="test1"
    img src="123.jgp" id="test2"


    Here is the Javascript function for image or div rotation.



    function rotateDiv(childDiv){
    //FOR IE 1=>90, 2=>180, 3=>270, 4=>360//filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=4);
    var style_rotate = $("#"+childDiv).attr("style");
    var checkIndex = $("#"+childDiv).attr("style");
    if(checkIndex.indexOf("(rotation=4)") != -1 || checkIndex.indexOf("rotate(360deg)") != -1){
    style_rotate = style_rotate+"-moz-transform: rotate(90deg);filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);";
    }
    else if(checkIndex.indexOf("(rotation=1)") != -1 || checkIndex.indexOf("rotate(90deg)") != -1){
    style_rotate = style_rotate+"-moz-transform: rotate(180deg);filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);";
    }
    else if(checkIndex.indexOf("(rotation=2)") != -1 || checkIndex.indexOf("rotate(180deg)") != -1) {
    style_rotate = style_rotate+"-moz-transform: rotate(270deg);filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);";
    }
    else if(checkIndex.indexOf("(rotation=3)") != -1 || checkIndex.indexOf("rotate(270deg)") != -1) {
    style_rotate = style_rotate+"-moz-transform: rotate(360deg);filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=4);";
    }
    $("#"+childDiv).attr("style",style_rotate);

    }

    Friday, September 24, 2010

    Keeping background colors in printing

    Internet Explorer:
    - 'Tools' menu
    - 'Internet Options...' menu item
    - 'Advanaced' tab
    - 'Print background colors and images' checkbox

    Mozilla:
    - 'File' menu
    - 'Page Setup...' menu item
    - 'Print Background (colours & images)' checkbox

    Thursday, September 23, 2010

    Drupal Mysql Query

    Some of the Mysql Statement in drupal

    1. use db_query instead mysql_query

    2. mysql_insert_id = db_last_insert_id

    3. mysql_fetch_array = db_fetch_array

    Wednesday, June 23, 2010

    Error Checking with HTTP Status Codes in Ajax

    Error checking is very important when working with AJAX. If you are inserting data directly into a page, you must ensure at the least that the request completed succesfully. While the request may have been completed (determined by a ready state of 4 - see above), it may not have been succesful - for example, if the page was not found, or if access was denied. We can handle this using HTTP status codes.
    You will be familiar with the most commonly seen status code - 404, or file not found. The most commonly used code, however, is 200 - OK. We can check the HTTP status code returned by the web server using the status property of the XMLHttpRequest object. So, our previous example should check that the ready state is 4 and the status code is 200:
    xhrobj.onreadystatechange = function()
    {
      if (xhrobj.readyState == 4 && xhrobj.status == 200)
      {
        if (xhrobj.responseText)
        {
         document.write(xhrobj.responseText);
        }
      }
    };

    Common status codes

    Here is a list of common status codes:
    200 OK
    400 Bad Request
    403 Forbidden
    404 Not Found
    50x Server Errors
    500 Internal Server Error

    Convert String Into object using javascript

    Convert String Into object using javascript:

    How to get a input value from the string using javascript.
    Use "eval" function to get input value from the string.

    Example:
    <form>
      <input type="text" name="test" id="test" value="1" />
      <input type="button" name="te" onclick="testing()" />
    </form>

    <script>
      function testing() {
       var st = "document.getElementById('test').value";
       alert(st);
    //output:  document.getElementById('test').value
      //output : 1
       alert(eval(st));
      //output : 1
      }
    </script>

    Monday, June 14, 2010

    Graphical Pie Chart With Google Chart API in 3 steps


    Download the latest version package from this link - http://code.google.com/p/googchart/


    Step 1:

    Include the API class file in the PHP file where you want to Display the Chart

    include( 'GoogChart.class.php' );


    Step 2:

    Assign the datas which should be charted in the array variable say $data like below

    $data = array(
    'IE7' => 22,
    'IE6' => 30.7,
    'IE5' => 1.7,
    'Firefox' => 36.5,
    'Mozilla' => 1.1,
    'Safari' => 2,
    'Opera' => 1.4,
    );
    Set the Graph Color of your choice here in a array variable called $color
    // Set graph colors
    $color = array(
    '#99C754',
    '#54C7C5',
    '#999999',
    );

    Step 3:

    Finally building the Chart and printing it.

    $chart->setChartAttrs( array(
    'type' => 'pie',
    'title' => 'Browser market 2008',
    'data' => $data,
    'size' => array( 400, 300 ),
    'color' => $color
    ));

    // Print chart
    echo $chart;



    Output:

















    Supported types:

    • Pie
      Standard pie chart
    • Line
      Standard Line chart
    • Sparkline
      Almost identical to Line, except defaults to no axis lines.
    • Bar-horizontal
      Horizontal bar chart
    • Bar-vertical
      Vertical bar chart
    Note :Examples for these types are Available in example.php available when you download this package.

    Enjoy!



    List DB and Tables using PHP

    $conn = mysql_connect("localhost", "root", "") or die("Could not connect: " . mysql_error());
        //List DB
        $result = mysql_list_dbs( $conn );
        while( $row = mysql_fetch_object( $result ) ):
             echo  $row->Database "<br />";
        endwhile;

       //List Tables
      $db_name  = "test";
      $tables = mysql_list_tables("$db_name");
       while (list($table) = mysql_fetch_row($tables)) {
        $treeNodes->add($table,$table,$table,true,false,"","");
       }

      or
     $tables_list = mysql_query("SHOW TABLES FROM $db_name");

    Friday, May 14, 2010

    Get Last Value using PHP explode

     $hostname = "http://localhost/test/123.jpg";
                                     $expname = explode ("/", $hostname);
                                     // Point to the last element of array
                                     $lastV =  end($expname);
                                     // Get the current element of array
                                   $lastV =  pos($expname);

    Thursday, May 6, 2010

    How to make onclick automatically through onload function

    $().ready(function() {
    $('#someLinkId').click();
    });
    
    or 
    
    $().ready(function() {
    $('#someLinkId').trigger("click");
    });
    
    

    Wednesday, May 5, 2010

    Google address search & recursion sample

    function address_search() {
    global $languageCode; //search result in English/deutch/..etc., lang
    //for English - "en" is d code

    //search key from the form
    $inAddr = $_REQUEST['address'];
    //echo 'inn';exit;
    $items = array();
    $code = strtolower($languageCode);
    if(!$code) $code = 'en';
    $googleCode = 'xyz..';//here add ur google api key
    if($inAddr) {
    $json = json_decode(file_get_contents('http://maps.google.com/maps/geo?output=json&oe=utf8&sensor=false&hl='.$code.'&key='.$googleCode.'&q='.urlencode($inAddr)));
    if(!empty($json->Placemark)){
    foreach($json->Placemark as $value){
    if(!empty($value->AddressDetails)) {
    $address = getAddressDetails($value->AddressDetails);
    $items[$address] = $address;
    }
    }
    }
    }else {
    //echo 'else';
    }
    //print drupal_to_js($items);
    // exit;
    echo '
    ';print_r($items);exit;
    }

    function getAddressDetails(&$addressDetails) {
    static $country;
    static $state;
    static $city;
    static $zipCode;
    static $street;
    if(!empty($addressDetails) && count($addressDetails) > 0 && @is_object($addressDetails)) {
    //echo '
    ';print_r($addressDetails);exit;
    foreach ($addressDetails as $addrKey => $addrVal) {
    //echo $addrKey.'@@
    ';
    switch (strtolower($addrKey)) {
    case 'addressdetails':
    //getAddressDetails($addrVal);
    break;
    case 'country':
    $country = $addrVal->CountryName;
    //echo '
    ';
    //getAddressDetails($addrVal);
    break;
    case 'administrativearea':
    $state = $addrVal->AdministrativeAreaName;
    //getAddressDetails($addrVal);
    break;
    case 'subadministrativearea':
    $street .= $addrVal->SubAdministrativeArea;
    break;
    case 'locality':
    $city = $addrVal->LocalityName;
    //getAddressDetails($addrVal);
    break;
    case 'thoroughfare':
    $street = $addrVal->ThoroughfareName;
    //getAddressDetails($addrVal);
    break;
    case 'dependentlocality':
    $street = ' '.$addrVal->AddressLine[0];
    //getAddressDetails($addrVal);
    break;
    case 'postalcode':
    $zipCode = $addrVal->PostalCodeNumber;
    //getAddressDetails($addrVal);
    break;
    default:
    break;
    }
    if(!empty($addrVal) && @isset($addrVal)) {
    //echo '
    ---';print_r($addrVal);exit;
    getAddressDetails($addrVal);
    }
    }
    }
    return $addrKey = $street.', '.$city.', '.$state.', '.$country.', '.$zipCode;
    }

    Weird gwProxy code is inserted in WYSIWYG textareas


    Weird gwProxy code is inserted in WYSIWYG textareas

     



    When I edit a textarea that has a WYSIWYG editor like FCKeditor or JCE Editor 
    a code is inserted at the end. It happened to me with websites using drupal, but it seems it also happens with sites using Joomla and other CMS and blogs 
    This is the code:
    It does not happen with IE or Safari or when the textarea is not using one of the editors.
    This is the code:
    It does not happen with IE or Safari or when the textarea is not using one of the editors
    You can start Firefox in Safe Mode to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes). 
    See Troubleshooting extensions and themes 
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears. 
    You can use "Disable all add-ons" on the Safe mode start window. 
    You have to close and restart Firefox after each change (File > Exit).


    Note: Problem add on  is -> Browser Highlighter was the Bugger... Remove this addon

     

     

    Tuesday, May 4, 2010

    serialize and unserialize in PHP

    <?php 
    $a = array();  
    $a[0] = "blah"
     $a[1] =& $a
     $a[1][0] = "pleh"; // $a[0] === "pleh"  
    $b = unserialize(serialize($a));  
    // $b[0] == "pleh", $b[1][0] == "pleh"
    $b[1][0] = "blah"; 
    ?>

    now $b[1][0] == "blah", but $b[0] == "pleh"
    after serializing and unserializing, slice 1 is no longer a reference to the array itself... I have found no way around this problem... even manually modifying the serialized string from
    'a:2:{i:0;s:4:"pleh";i:1;a:2:{i:0;s:4:"pleh";i:1;R:3;}}'
    to
    'a:2:{i:0;s:4:"pleh";i:1;R:1;}'

    to force the second slice to be a reference to the first element of the serialization (the array itself), it seemed to work at first glance, but then unreferences it when you alter it again, observe:

    <?php
        $testser
    = 'a:2:{i:0;s:4:"pleh";i:1;R:1;}';

       
    $tmp = unserialize($testser);

       
    print_r($tmp);

        print
    "\n-----------------------\n";

       
    $tmp[1][0] = "blah";

       
    print_r($tmp);
     
    ?>

    outputs:
    Array
    (
        [0] => pleh
        [1] => Array
     *RECURSION*
    )

    -----------------------
    Array
    (
        [0] => pleh
        [1] => Array
            (
                [0] => blah
                [1] => Array
                    (
                        [0] => pleh
                        [1] => Array
     *RECURSION*
                    )

            )

    )

    Show something only on home page in WordPress

    Show some Contents only on home page in WordPress 
     
    Here is the solution to show content only in home page 
     
    <?php if( is_front_page() ) : ?>
         ///Your Content Here 
    <?php endif;?>



    Monday, May 3, 2010

    Firefox Add-ons for Web Developers & Designers

      ffaddons.PNG
    Firefox has cool add-ons which make the job of website designers and developers much easier. Here is our list of 30+ excellent Firefox add-ons that every web developer and designer should know about.
    CSS
    Aardvark (Aardvark) – A cool extension for web developers and designers, allows them to view CSS attributes, id, class by highlighting page element individually.
    chromEdit – Alter the appearance of any page by editing CSS and Javascript files with this extension.
    CSSMate – Firefox extension to edit CSS files.
    CSS validator – Check the validity of your webpage using this CSS validator extension.
    CSSViewer – See the CSS properties of page elements with this extension.
    EditCSS – Play around with loaded CSS, Web Developer extension also provides this functionality.
    IE Tab – Designers and developers can view their CSS projects on Internet Explorer () using this extension.
    Style Sheet Chooser II – Users can pick and choose alternate style sheets for a website.
    Debugging and Analysis
      firebug.PNG
    FireBug – A console for debugging JavaScript, HTML, and Ajax code snippets.
    HTML Validator – Cool extension to validate web pages with HTML standards of W3C.
    JavaScript Debugger – JavaScript debugging extension enables a strong debugging environment.

    Link Checker
    – Check the links on a webpage for validity. Color to each link explains its current status.

    Load Time Analyzer
    – View detailed graphs of the loading time of web pages in firefox. The graphs display events like page requests, image loading times etc.
    View Dependencies – Find out all files that were loaded in a webpage with the view dependencies tab in page info.
    Others
      xul.PNG

    Clipmarks
    – Easily save portions of webpage with this extension.

    Codetech
    – Excellent extension for web page designers, codetech is a web page editor with the look and feel of Dreamweaver.

    ColorZilla
    – A nice extension for web designers and developers. Colorzilla helps users to select colors which can be adjusted and put in any other program.
    FirePHP – Find out what PHP () code in the backend does to pages on display in Firefox browsers.

    Flash Switcher
    – Use this extension to avoid reloading between flash plugins.

    Greasemonkey – Control any aspect of web page behavior by adding Javascript code to any webpage using this Firefox extension.

    Measureit
    – Users can calculate the measurement specifications of tables, paragraphs on internet.

    Platypus
    – One of the best Firefox extensions for modifying a webpage. Users can modify a webpage, save their changes as a Greasemonkey script and their saved page would be loaded the next time they visit the page.

    Poster
    – A must have tool for web developers enabling them to interact with web services and other web resources.

    Professor X
    – Check out the contents of the head of page without getting into source code.
    Screen grab – Capture screenshot of any webpage and save it as an image file with this extension.
    TestGen4Web – Save the webpage activities users (entry of text, web page clicks) in xml file. These actions can later on be replayed and converted to scripts for automated test tools.
    View Source Chart – View the source code of any webpage as Firefox sees it.

    Web Developer
    – Add a menu of various web development tools with web developer extension.

    Saturday, May 1, 2010

    How to Delete Test Orders from Magento

    Deleting your test orders currently requires running a script directly on your Database. Make sure you fully backup your database before doing anything! This script will delete all orders in the database and reset all order counters!



    SET FOREIGN_KEY_CHECKS=0;
    TRUNCATE `sales_order`;
    TRUNCATE `sales_order_datetime`;
    TRUNCATE `sales_order_decimal`;
    TRUNCATE `sales_order_entity`;
    TRUNCATE `sales_order_entity_datetime`;
    TRUNCATE `sales_order_entity_decimal`;
    TRUNCATE `sales_order_entity_int`;
    TRUNCATE `sales_order_entity_text`;
    TRUNCATE `sales_order_entity_varchar`;
    TRUNCATE `sales_order_int`;
    TRUNCATE `sales_order_text`;
    TRUNCATE `sales_order_varchar`;
    TRUNCATE `sales_flat_quote`;
    TRUNCATE `sales_flat_quote_address`;
    TRUNCATE `sales_flat_quote_address_item`;
    TRUNCATE `sales_flat_quote_item`;
    TRUNCATE `sales_flat_quote_item_option`;
    TRUNCATE `sales_flat_order_item`;
    TRUNCATE `sendfriend_log`;
    TRUNCATE `tag`;
    TRUNCATE `tag_relation`;
    TRUNCATE `tag_summary`;
    TRUNCATE `wishlist`;
    TRUNCATE `log_quote`;
    TRUNCATE `report_event`;
    ALTER TABLE `sales_order` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
    ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
    ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
    ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
    ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
    ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
    ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
    ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
    ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
    ALTER TABLE `tag` AUTO_INCREMENT=1;
    ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
    ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
    ALTER TABLE `wishlist` AUTO_INCREMENT=1;
    ALTER TABLE `log_quote` AUTO_INCREMENT=1;
    ALTER TABLE `report_event` AUTO_INCREMENT=1;
    -- reset customers
    TRUNCATE `customer_address_entity`;
    TRUNCATE `customer_address_entity_datetime`;
    TRUNCATE `customer_address_entity_decimal`;
    TRUNCATE `customer_address_entity_int`;
    TRUNCATE `customer_address_entity_text`;
    TRUNCATE `customer_address_entity_varchar`;
    TRUNCATE `customer_entity`;
    TRUNCATE `customer_entity_datetime`;
    TRUNCATE `customer_entity_decimal`;
    TRUNCATE `customer_entity_int`;
    TRUNCATE `customer_entity_text`;
    TRUNCATE `customer_entity_varchar`;
    TRUNCATE `log_customer`;
    TRUNCATE `log_visitor`;
    TRUNCATE `log_visitor_info`;
    ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
    ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
    ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
    ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
    ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
    ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
    ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
    ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
    ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
    ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
    ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
    ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
    ALTER TABLE `log_customer` AUTO_INCREMENT=1;
    ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
    ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
    -- Reset all ID counters
    TRUNCATE `eav_entity_store`;
    ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=1;
    SET FOREIGN_KEY_CHECKS=1;

    Friday, April 30, 2010

    How to Display HTML/JavaScript Codes on Blogger Posts

    Recently, a reader queried me this little doubt. How do I show the HTML/JavaScript codes on my Blogger posts? So, I decided to post it as a tidbit here.

    Your HTML code has tags, enclosed in angle brackets (< and >). All you need to do is replace these angle brackets with these:

    In place of <, use < and in place of >, use >. Keep everything else the same and publish your code, it will be shown as code itself on the published post.

    Example:

    In place of this code:
    <a href="http://.com">yes</a>
    you will use:
    <a href="http://.com">yes</a>

    Magento: Display Categories in Sidebar



    It seems my posts lately are always in relation to solving a problem or answering a question for someone else. If you’re looking for a way to display categories in the sidebar, change category display, or create a category menu then this post is probably for you.

    Creating the Block

    The first thing you need to do is create a block in your layout. Navigate to /app/design/frontend/default/default/layout/catalog.xml
    The first thing in your layout is a definition of the default layout noted by the comment “Default layout, loads most of the pages” depending on where you want to put your category nav (right sidebar, left sidebar, footer, etc) you’ll need to define the block a little differently. I’m going to do it with the left sidebar so you see what’s going on.

    <reference name="left">
                <block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/left_nav.phtml" />
    </reference>


    Okay, so what i did was locate the left sidebar which is referenced simply as “left” inside those tags i define my block type and template. The next thing you’ll want to do is create that template file, note that i defined it within /app/design/frontend/default/default/template/catalog/navigation/left_nav.phtml so i will need to create that file.

    Creating the Template

    Once I’ve created the file, it’s time to put in my code to populate my links automatically of all my categories:


    <h2>Browse</h2>
    <div class="block">
    <ul id="nav_category" class="nav_category">
        <?php foreach ($this->getStoreCategories() as $_category): ?>
            <?php echo $this->drawItem($_category) ?>
        <?php endforeach ?>
    </ul>
    </div>
    <?php echo $this->getChildHtml('topLeftLinks') ?>

     If you want to take this a step further, you can target subcategories based on current page with this little script (via Pratthost

    <?php
    $obj = new Mage_Catalog_Block_Navigation();
    $store_cats    = $obj->getStoreCategories();
    $current_cat     = $obj->getCurrentCategory();
    $current_cat    = (is_object($current_cat) ? $current_cat->getName() : '');
     
    foreach ($store_cats as $cat) {
        if ($cat->getName() == $current_cat) {
            echo '<li class="current"><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a>\n<ul>\n";
            foreach ($obj->getCurrentChildCategories() as $subcat) {
                echo '<li><a href="'.$this->getCategoryUrl($subcat).'">'.$subcat->getName()."</a></li>\n";
            }
            echo "</ul>\n</li>\n";
        } else {
            echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."</a></li>\n";
        }
    }
    ?>
     

    Followers