Ads Inside Post

Search in This Blog

Remove version number from JS and CSS in WordPress

Problem:


How to Remove version number / querystring from JS and CSS in WordPress.

Solution:

goto your active theme folder and open functions.php file
and add below lines at the bottom.

function del_queryandversion_from_css_js( $style_or_js_url ) {
if ( strpos( $style_or_js_url, 'ver=' ) )
$css_js = remove_query_arg( 'ver', $style_or_js_url );
return $css_js;
}
add_filter( 'style_loader_src', 'del_queryandversion_from_css_js', 10 );
add_filter( 'script_loader_src', 'del_queryandversion_from_css_js', 10 );

How to use ON DUPLICATE KEY in insert statement

How to use ON DUPLICATE KEY in insert statement

Problem:
In case of inserting or updating record we use separate logic using if statement or case statement:
e.g.:

if(i==0)
insert here

if(i=1)
update here

we can terminate the above if statement by using On Duplicate Key.
by using this only one statement can be use for insert and update record.

*note: user_nm coulmn must be unique

Example:

INSERT INTO `posts` (`user_nm`, `no_of_update`, `inserted_on`, `update_on`)
VALUES ('a_user', 1, NOW(), NOW())
ON DUPLICATE KEY
UPDATE `no_of_update` = `no_of_update` + 1, `update_on` = NOW()



















Mysql Database access using PDO

How to access Mysql Database using PDO:

PHP is changing day by day. in old days we were use mysql_connect(...) but now in current days it is not supported. current days we can use mysqli_connect(...). but it is better if we use PDO (PHP Data Object).

PHP Data Objects (PDO) is a very lightweight, consistent interface for accessing different types of databases in PHP. for this you simply tell the PDO database driver.

by using PDO you use the same functions to issue queries and fetch data in different types of database. PDO also remove all possibility of sql injections. for this it provide bind parameter facility.

Example:

Listed below full code that insert update delete list of all records. this code is in OOP based.


File: Db.php

<?php
class Db {
    private $pdo;
    private $stmt;

    function __construct() {
// set database setting here
$host='localhost'; $db='student_db'; $u='root'; $p='';
        try {
$this->pdo = new PDO("mysql:host={$host};dbname={$db}", $u,$p);
          $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch(PDOException $e) {
            $this->pdo = null;
echo $e->getMessage();
            return 'oops: ' . $e->getMessage();
        }
    }

    function __destruct() {
// release all resource
        $this->stmt = null;
        $this->pdo = null;
    }

// initialize prepare statement
    public function prepare_statement($sql) {
        $this->stmt = $this->pdo->prepare($sql);
    }

// bind parameter
    public function set_val($field_nm, $field_val) {
        $this->stmt->bindParam($field_nm, $field_val);
    }

// initialize prepare statement for update data using array
public function update_by_array($tbl_name, $where, $array_data) {
$sets="Update {$tbl_name} set ";
foreach ($array_data as $field => $value) {
$sets .= "{$field} = :{$field}, ";
}
$sets= substr($sets,0,-2).$where;
$this->prepare_statement($sets);
foreach ($array_data as $field => $value) {
$this->set_val(":{$field}", $value);
}
        return $this->exe_update_insert();
    }

//////// execute statement and return records from mysql
    public function get_record_exe_stat() {
        try {
            $this->stmt->execute();
            return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
        } catch(PDOException $e) {
echo $e->getMessage();
            $this->pdo = null;
            return 'oops: ' . $e->getMessage();
        }
    }

/// execute statement and return updated/inserted no of rows/row
    public function exe_update_insert() {
        try {
           
$this->stmt->execute();
//$this->stmt->debugDumpParams();
            return $this->stmt->rowCount();
        } catch(PDOException $e) {
//$this->stmt->debugDumpParams();
//echo $e->getMessage();
            $this->pdo = null;
            return 'oops: ' . $e->getMessage();
        }
    }

/// Return number of rows that are after delete/update/insert
    public function get_row_count() {
        try {
            $this->stmt->rowCount();
        } catch(PDOException $e) {
echo $e->getMessage();
            $this->pdo = null;
            return 0;
        }
    }
/// Return last auto increment id after insert record
    public function get_last_id() {
        try {
            return $this->pdo->lastInsertId();
        } catch(PDOException $e) {
$this->pdo = null;
            return 0;
        }
    }
/// Return records of sql query
    public function get_record_by_sql($sql)
    {
        try {
            $stmt = $this->pdo->prepare($sql);
            $stmt->execute();
            return $stmt->fetchAll(PDO::FETCH_ASSOC);
        } catch(PDOException $e) {
echo $e->getMessage();
            $this->pdo = null;
            return 'oops: ' . $e->getMessage();
        }
    }
/// Insert record and return number of rows effected
    public function insert_by_sql($sql)
    {
        try {
            $stmt = $this->pdo->prepare($sql);
            $stmt->execute();
            return $stmt->rowCount();
        } catch(PDOException $e) {
echo $e->getMessage();
            $this->pdo = null;
            return 'oops: ' . $e->getMessage();
        }
    }
}



test.php

<?php
require_once('Db.php');
$db= new Db();
$i=0;

///// simple insert //////////
$number_of_rows_updated=$db->insert_by_sql("insert into std_info(std_full_nm,address,phone,class_cat) values ('xyz name','address123','1231231234','class 3')");

/////////////////////////insert by bind parameter prepare statement /////////////////////////////////////////////////////////
for($i=1;$i<=10;$i++) {
$std_full_nm = "AA".$i;
$address = "12/76 my address".$i;
$phone='12345678'.$i;
$class_cat='class'.$i;
$db->prepare_statement("insert into std_info(std_full_nm,address,phone,class_cat) values (:std_full_nm,:address,:phone,:class_cat)");
$db->set_val(":std_full_nm", $std_full_nm);
$db->set_val(":address", $address);
$db->set_val(":phone", $phone);
$db->set_val(":class_cat", $class_cat);
$up = $db->exe_update_insert();
if($up>=1){
$id=$db->get_last_id();
echo "Last id is =". $id."<br/>";
}
}

//////////////// return multiple row by prepare statement ////////////////////////////////////////////////////////////////
$id = "1";
$db->PrepareStatement("SELECT * FROM std_info WHERE std_id>= :id");
$db->set_val(":id", $id);
$userData = $db->get_record_exe_stat();
print_r($userData);
if (count($userData) < 1)
return;
for($i=0;$i<count($userData);$i++) {
echo $userData[$i]['std_id']."<br/>";
echo $userData[$i]['std_full_nm']."<br/>";
echo $userData[$i]['address']."<br/>";
echo $userData[$i]['phone']."<br/>";
echo $userData[$i]['class_cat']."<br/>";
echo "<hr/>";
}

///////////////////// return single row //////////////
$id = "1";
$db->PrepareStatement("SELECT * FROM std_info WHERE std_id= :id");
$db->set_val(":id", $id);
$userData = $db->get_record_exe_stat();
if (count($userData)>= 1) {
echo $userData[0]['std_id']."<br/>";
echo $userData[0]['std_full_nm']."<br/>";
echo $userData[0]['address']."<br/>";
echo $userData[0]['phone']."<br/>";
echo $userData[0]['class_cat']."<br/>";
echo "<hr/>";
}

///////////// update by using bind parameter ////////////////
$std_id = "1"; // Some ID to update
$std_full_nm = "zz";
$address = "55/76 my address";
$phone='0987654321';
$class_cat='10 class';

$db->prepare_statement("UPDATE std_info SET std_full_nm=:std_full_nm,address=:address,phone=:phone,class_cat=:class_cat WHERE std_id=:std_id");
$db->set_val(":std_id", $std_id);
$db->set_val(":std_full_nm", $std_full_nm);
$db->set_val(":address", $address);
$db->set_val(":phone", $phone);
$db->set_val(":class_cat", $class_cat);
$updated_row = $db->exe_update_insert();

///////////// update by using array ////////////////
$tbl_name='std_info';
$where=' WHERE std_id=1';
$sets = "";
$array_data = array(
'std_full_nm' => 'somename1',
'address' => 'someaddress1',
'phone' => 'Somephone1',
'class_cat' => 'Somecat1'
);
$db->update_by_array($tbl_name,$where, $array_data);

/////////////////// return records by simple sql //////////////
$id = "1";
$userData = $db->get_record_by_sql("SELECT * FROM std_info");
if (count($userData) < 1)
return;
for($i=0;$i<count($userData);$i++) {
echo $userData[$i]['std_id']."<br/>";
echo $userData[$i]['std_full_nm']."<br/>";
echo $userData[$i]['address']."<br/>";
echo $userData[$i]['phone']."<br/>";
echo $userData[$i]['class_cat']."<br/>";
echo "<hr/>";
}

PDOException' with message 'SQLSTATE[42000 Syntax error or access violation: 1064

Problem:


How to fix following PHP PDO error
exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line


Solution:


It means you are missing small brackets ')' in your sql statement.

Video Watermark Remover

Problem:

Some time you have many videos that has watermark. you just hate that watermark and need to delete it. There are many watermark remover software but all are not free. so if you want a free video watermark remover then you are at present here right place.

Solution:


I have developed Video watermark remover software. it is 64 Bit Windows 7 desktop application, so you needed to .net framework 4.5 to run this application.




You can download it from here:

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part01.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part02.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part03.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part04.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part05.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part06.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part07.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part08.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part09.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part10.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part11.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part12.rar

http://sourceforge.net/projects/unique-softwares/files/VideoWaterMarkRemover.part13.rar



Microsoft Office Interop Outlook

Problem:

Where to find library of Microsoft.Office.Interop.Outlook?

Solution:

To locate library of Microsoft.Office.Interop.Outlook you should look into below 2 folders:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office14
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15


Please note that folder could be "C:\Program Files\"

mongoDB on windows 7

Problem:


While installing mongoDB on windows 7 you will get the same message as below:

I CONTROL  Hotfix KB2731284 or later update is not installed, will zero-out data files
I STORAGE  [initandlisten] exception in initAndListen: Data directory C:\data\db\ not found., terminating
I CONTROL  [initandlisten] dbexit:  rc: 100Solution:


Solution:

you needed o create "data\db" folder under "C:\mongodb\bin" and run mongod.exe file then after it will automatically create "C:\data\db\"

how to check if visitor is a robot or bot

Problem:

how to check if visitor is a robot or bot?

Solution:

Please use below code

Example:

$user_agent='';
if( !isset( $_SERVER['HTTP_USER_AGENT'])){
echo 'i m a Robot!';
die();
} else {
$user_agent=strtolower($_SERVER['HTTP_USER_AGENT']);
}

$robot='N';
if(strpos($user_agent,'bot')>0 || strpos($user_agent,'Bot')>0) {
    $robot='Y';
}

if($robot!='Y')
echo 'I am not a Robot';
else
echo 'I am a Robot';




Currency convertor

Problem:  

Some time you need to convert currency into different countries, so what you will do?

Solution: 

You can use yahooapi

Example: 

Use below code. the code is in PHP ou can easily convert it into VB.Net, Java, C# etc if you are good programmer.


function curr_convert($ffrom,$tto,$iinput) {
$yql_url = "http://query.yahooapis.com/v1/public/yql";
    $yql_query = 'select * from yahoo.finance.xchange where pair in ("'.$ffrom.$tto.'")';
    $yql_query_full_url = $yql_url . "?q=" . urlencode($yql_query);
    $yql_query_full_url .= "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
    $yql_curl = curl_init($yql_query_full_url);
    curl_setopt($yql_curl, CURLOPT_RETURNTRANSFER,true);
    $yqlcurl_exec = curl_exec($yql_curl);
    $yql_json =  json_decode($yqlcurl_exec,true);
    $curr_output = (float) $iinput*$yql_json['query']['results']['rate']['Rate'];
    return $curr_output;
}
$result = curr_convert($ffrom = "USD", $tto = "INR", $iinput = 1);
echo '1 USD  = '.$result.' INR';

How to change or add some extra js file in Joomla

Problem:

How to change or add some extra js file in Joomla


Solution:


Open file from this location
libraries\joomla\document\html\renderer\head.php




Product color drop down is not sort order in magento admin panel

Problem:

In Magento admin Manage product section drop down is not in sort order.

Product color drop down is not sort order in magento admin panel


Go into backend magento admin ----> catalog ----> Manage Products --- under product colour when you click on a colour a dropdown will appear ---- then this will give you a list of colours
For some reason the colours are not in alphabetical order
See the image

drop down is not in sort order



Solution:

just open the file "app/design/adminhtml/default/default/template/catalog/product.phtml"
and paste below code. Please note that I am still working on this issue and updating the script so please wait. till than you can use the script

<script>
var $j = jQuery.noConflict();
function SortBox(x, y) {
    if (x.innerHTML == 'NA') {
        return 1;
    }
    else if (y.innerHTML == 'NA') {
        return -1;
    }
    return (x.innerHTML > y.innerHTML) ? 1 : -1;
}

function dook(){
 $j('select').each(function( index ) {
     $j(this).find('option').sort(SortBox).appendTo($(this));
});
}
var myVar = setInterval(function(){ dook() }, 5000);
</script>

is it safe to remove version numbers from .js in vBulletin

Problem:

is it safe to remove version numbers from .js in vBulletin?

Solution:

yes, it is safe to delete version number from .js in vBulletin.

Unable to access an error message corresponding to your field name

Problem:

While working with CodeIgniter in-build set validation with text box for ex: invalid email or empty filed you may face this error "Unable to access an error message corresponding to your field name"

It means you have not set correctly error setup.
$this->form_validation->set_rules('blink', 'Link', 'required|trim|');

filezilla Error Connection timed out Error File transfer failed after transferring

Problem:


While uploading more that 100 KBs file size FileZilla could show you error message as below:
"filezilla Error Connection timed out Error File transfer failed after transferring"

Solution:

This is the due to timeout connection. so increase it.

Example:

Goto Edit-->Setting...-->Connection
In timeout section change Timeout in seconds to 300.
Now error "filezilla Error Connection timed out Error File transfer failed after transferring" will gone.

The system cannot find the file specified. Exception from HRESULT:0x80070002

Problem:


While working with ASP.Net MVC 5 when you create a web project get the error and project will not create:
"The system cannot find the file specified. Exception from HRESULT:0x80070002"

Solution:

Repair you Visual Studio 2013 or 2015 and problem will gone.

Parse XML in PHP with Attributes

Problem:
How to Parse XML in PHP with Attributes
Listed below the XML data.
Suppose you have a url which produce below XML data on request and you want to parse it in PHP including it's attribute for ex:  spell id="168839" minCount="1" maxCount="1" etc.

See below XML for full information:
<?xml version="1.0" encoding="utf-8"?>
<wowhead><item id="114811">
  <name>Hexweave Leggings</name>
  <level>640</level>
  <quality id="4">Epic</quality>
  <class id="4">Armor</class>
  <subclass id="1">Cloth Armor</subclass>
  <icon displayId="132245">inv_cloth_draenorcrafted_d_01pants</icon>
  <inventorySlot id="7">Legs</inventorySlot>
  <htmlTooltip>
    <table>
      <tr>
        <td><!--nstart-->
          <b class="q4">Hexweave Leggings</b>
          <!--nend--><!--ndstart--><!--ndend-->
          <span style="color: #ffd100">
            <br />
            Item Level<!--ilvl-->640</span>
          <br />
          <!--bo-->Binds when equipped
          <br />
          Unique-Equipped: Warlords Crafted (3)
          <table width="100%">
            <tr>
              <td>Legs</td>
              <th>Cloth</th>
            </tr>
          </table>
          <span><!--amr-->83 Armor</span>
          <br />
          <!--re-->
          <span class="q2">&lt;Random enchantment&gt;</span>
          <br />
          <span><!--stat5-->+184 Intellect</span>
          <br />
          <span><!--stat7-->+275 Stamina</span>
          <!--ebstats--><!--egstats--><!--e--><!--ps-->
          <br />
          Durability 120 / 120</td>
      </tr>
    </table>
    <table>
      <tr>
        <td>Requires Level<!--rlvl-->91
          <div class="whtt-sellprice">Sell Price:
            <span class="moneygold">41</span>
            <span class="moneysilver">61</span>
            <span class="moneycopper">90</span>
          </div>
        </td>
      </tr>
    </table>
  </htmlTooltip>
  <json>"appearances":{"6":[132245,""],"7":[132269,""],"8":[132254,""]},"armor":83,"bonustrees":[184],"classs":4,"displayid":132245,"flags2":8192,"id":114811,"level":640,"name":"4Hexweave Leggings","reqlevel":91,"slot":7,"slotbak":7,"source":[1],"sourcemore":[{"c":11,"icon":"inv_cloth_draenorcrafted_d_01pants","n":"Hexweave Leggings","s":197,"t":6,"ti":168839}],"specs":[64,256,63,62,257,265,258,266,267],"subclass":1</json>
  <jsonEquip>"appearances":{"6":[132245,""],"7":[132269,""],"8":[132254,""]},"armor":83,"avgbuyout":53990000,"displayid":132245,"dura":120,"int":184,"reqlevel":91,"sellprice":416190,"slotbak":7,"sta":275</jsonEquip>
  <createdBy>
    <spell id="168839" name="Hexweave Leggings" icon="inv_cloth_draenorcrafted_d_01pants" minCount="1" maxCount="1">
      <reagent id="111556" name="Hexweave Cloth" quality="2" icon="inv_tailoring_hexweavethread" count="100"/>
      <reagent id="110609" name="Raw Beast Hide" quality="1" icon="inv_misc_nativebeastskin" count="4"/>
    </spell>
  </createdBy>
  <link>http://www.wowhead.com/item=114811</link>
  </item></wowhead>


Solution:

Using simplexml_load_file we can parse XMl data.

Example:

<?php
$url='http://www.wowhead.com/item=114811&xml';
$xml = simplexml_load_file($url) or die("feed not loading");
foreach($xml->item  as $items){
    echo $items->name . "<br>";
echo $items->level . "<br>";
echo $items->quality . "<br>";
echo $items->quality['id'] . "<br>";
echo $items->class . "<br>";
echo $items->class['id'] . "<br>";
echo $items->subclass . "<br>";
echo $items->subclass['id'] . "<br>";
echo $items->icon . "<br>";
echo $items->icon['displayId'] . "<br>";
echo $items->inventorySlot . "<br>";
echo $items->inventorySlot['id'] . "<br>";
echo $items->htmlTooltip . "<br>";
echo $items->json . "<br>";
echo $items->jsonEquip . "<br>";
echo $items->createdBy->spell  . " : ";
echo $items->createdBy->spell['id']  ." : ";
echo $items->createdBy->spell['name']  ." : ";
echo $items->createdBy->spell['icon']  . " : ";
echo $items->createdBy->spell['minCount']  ." : ";
echo $items->createdBy->spell['maxCount']  . "<br>";
$created_by_count=0;
foreach($items->createdBy->spell  as $myspel){
if($myspel->count()>=1) {
    foreach($myspel as $child) {
                  $created_by_count++;
      echo $child->getName(). ' : '. $child['id']. ' : ' .$child['name'] . ' : ' . $child['quality']. ' : ' . $child['icon']. ' : ' . $child['count'] . '<br/>';
}
  }
  echo 'Count createdBy='.$created_by_count. "<br>";
echo $items->link . "<br>";
}
}
?>

How to use jquery dataTables

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link href="jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
 <script src="jquery.js"></script>
 <script src="jquery.dataTables.min.js"></script>

</head>

<body>

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>

    <tfoot>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </tfoot>

    <tbody>
        <tr>
            <td>A111111111111</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>B1111111111111</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
        <tr>
            <td>C1111111</td>
            <td>Junior Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$86,000</td>
        </tr>
        <tr>
            <td>D111111111111</td>
            <td>Senior Javascript Developer</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2012/03/29</td>
            <td>$433,060</td>
        </tr>
        <tr>
            <td>E11111111111</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>33</td>
            <td>2008/11/28</td>
            <td>$162,700</td>
        </tr>
        <tr>
            <td>F111111111111</td>
            <td>Integration Specialist</td>
            <td>New York</td>
            <td>61</td>
            <td>2012/12/02</td>
            <td>$372,000</td>
        </tr>
        <tr>
            <td>G1111111111111</td>
            <td>Sales Assistant</td>
            <td>San Francisco</td>
            <td>59</td>
            <td>2012/08/06</td>
            <td>$137,500</td>
        </tr>
        <tr>
            <td>H11111111111</td>
            <td>Integration Specialist</td>
            <td>Tokyo</td>
            <td>55</td>
            <td>2010/10/14</td>
            <td>$327,900</td>
        </tr>
        <tr>
            <td>I22222222222222222</td>
            <td>Javascript Developer</td>
            <td>San Francisco</td>
            <td>39</td>
            <td>2009/09/15</td>
            <td>$205,500</td>
        </tr>
        <tr>
            <td>J11111111111111</td>
            <td>Software Engineer</td>
            <td>Edinburgh</td>
            <td>23</td>
            <td>2008/12/13</td>
            <td>$103,600</td>
        </tr>
        <tr>
            <td>K1111111111111</td>
            <td>Office Manager</td>
            <td>London</td>
            <td>30</td>
            <td>2008/12/19</td>
            <td>$90,560</td>
        </tr>
        <tr>
            <td>L111111111111</td>
            <td>Support Lead</td>
            <td>Edinburgh</td>
            <td>22</td>
            <td>2013/03/03</td>
            <td>$342,000</td>
        </tr>
        <tr>
            <td>M1111111111111</td>
            <td>Regional Director</td>
            <td>San Francisco</td>
            <td>36</td>
            <td>2008/10/16</td>
            <td>$470,600</td>
        </tr>
        <tr>
            <td>N11111111111111</td>
            <td>Senior Marketing Designer</td>
            <td>London</td>
            <td>43</td>
            <td>2012/12/18</td>
            <td>$313,500</td>
        </tr>
        <tr>
            <td>O1111111111111</td>
            <td>Regional Director</td>
            <td>London</td>
            <td>19</td>
            <td>2010/03/17</td>
            <td>$385,750</td>
        </tr>
        <tr>
            <td>P11111111111111</td>
            <td>Marketing Designer</td>
            <td>London</td>
            <td>66</td>
            <td>2012/11/27</td>
            <td>$198,500</td>
        </tr>
        <tr>
            <td>Q1111111111111111</td>
            <td>Chief Financial Officer (CFO)</td>
            <td>New York</td>
            <td>64</td>
            <td>2010/06/09</td>
            <td>$725,000</td>
        </tr>
        <tr>
            <td>R111111111111111</td>
            <td>Systems Administrator</td>
            <td>New York</td>
            <td>59</td>
            <td>2009/04/10</td>
            <td>$237,500</td>
        </tr>
        <tr>
            <td>S11111111111111</td>
            <td>Software Engineer</td>
            <td>London</td>
            <td>41</td>
            <td>2012/10/13</td>
            <td>$132,000</td>
        </tr>
        <tr>
            <td>T11111111111111</td>
            <td>Personnel Lead</td>
            <td>Edinburgh</td>
            <td>35</td>
            <td>2012/09/26</td>
            <td>$217,500</td>
        </tr>
        <tr>
            <td>U1111111111111</td>
            <td>Development Lead</td>
            <td>New York</td>
            <td>30</td>
            <td>2011/09/03</td>
            <td>$345,000</td>
        </tr>
        <tr>
            <td>V1111111111111</td>
            <td>Chief Marketing Officer (CMO)</td>
            <td>New York</td>
            <td>40</td>
            <td>2009/06/25</td>
            <td>$675,000</td>
        </tr>
        <tr>
            <td>W1111111111111</td>
            <td>Pre-Sales Support</td>
            <td>New York</td>
            <td>21</td>
            <td>2011/12/12</td>
            <td>$106,450</td>
        </tr>
        <tr>
            <td>X11111111111111</td>
            <td>Sales Assistant</td>
            <td>Sidney</td>
            <td>23</td>
            <td>2010/09/20</td>
            <td>$85,600</td>
        </tr>
        <tr>
            <td>Y111111111111111</td>
            <td>Chief Executive Officer (CEO)</td>
            <td>London</td>
            <td>47</td>
            <td>2009/10/09</td>
            <td>$1,200,000</td>
        </tr>
        <tr>
            <td>Z1111111111111</td>
            <td>Developer</td>
            <td>Edinburgh</td>
            <td>42</td>
            <td>2010/12/22</td>
            <td>$92,575</td>
        </tr>
        <tr>
            <td>A222222222222</td>
            <td>Regional Director</td>
            <td>Singapore</td>
            <td>28</td>
            <td>2010/11/14</td>
            <td>$357,650</td>
        </tr>
        <tr>
            <td>A33333333333333</td>
            <td>Software Engineer</td>
            <td>San Francisco</td>
            <td>28</td>
            <td>2011/06/07</td>
            <td>$206,850</td>
        </tr>
        <tr>
            <td>A44444444444444</td>
            <td>Chief Operating Officer (COO)</td>
            <td>San Francisco</td>
            <td>48</td>
            <td>2010/03/11</td>
            <td>$850,000</td>
        </tr>
        <tr>
            <td>A5555555555555</td>
            <td>Regional Marketing</td>
            <td>Tokyo</td>
            <td>20</td>
            <td>2011/08/14</td>
            <td>$163,000</td>
        </tr>
        <tr>
            <td>A6666666666666666</td>
            <td>Integration Specialist</td>
            <td>Sidney</td>
            <td>37</td>
            <td>2011/06/02</td>
            <td>$95,400</td>
        </tr>
        <tr>
            <td>A777777777777</td>
            <td>Developer</td>
            <td>London</td>
            <td>53</td>
            <td>2009/10/22</td>
            <td>$114,500</td>
        </tr>
        <tr>
            <td>A888888888888888</td>
            <td>Technical Author</td>
            <td>London</td>
            <td>27</td>
            <td>2011/05/07</td>
            <td>$145,000</td>
        </tr>
        <tr>
            <td>A99999999999999999</td>
            <td>Team Leader</td>
            <td>San Francisco</td>
            <td>22</td>
            <td>2008/10/26</td>
            <td>$235,500</td>
        </tr>
        <tr>
            <td>A100000000000000000</td>
            <td>Post-Sales support</td>
            <td>Edinburgh</td>
            <td>46</td>
            <td>2011/03/09</td>
            <td>$324,050</td>
        </tr>
        <tr>
            <td>A121212121212121111</td>
            <td>Marketing Designer</td>
            <td>San Francisco</td>
            <td>47</td>
            <td>2009/12/09</td>
            <td>$85,675</td>
        </tr>
        <tr>
            <td>AAAAAAAAAAAAAAAA</td>
            <td>Office Manager</td>
            <td>San Francisco</td>
            <td>51</td>
            <td>2008/12/16</td>
            <td>$164,500</td>
        </tr>
        <tr>
            <td>BBBBBBBBBBBBBBBB</td>
            <td>Secretary</td>
            <td>San Francisco</td>
            <td>41</td>
            <td>2010/02/12</td>
            <td>$109,850</td>
        </tr>
        <tr>
            <td>CCCCCCCCCCCCCC</td>
            <td>Financial Controller</td>
            <td>San Francisco</td>
            <td>62</td>
            <td>2009/02/14</td>
            <td>$452,500</td>
        </tr>
        <tr>
            <td>DDDDDDDDDDDDDDDD</td>
            <td>Office Manager</td>
            <td>London</td>
            <td>37</td>
            <td>2008/12/11</td>
            <td>$136,200</td>
        </tr>
        <tr>
            <td>EEEEEEEEEEEEEEE</td>
            <td>Director</td>
            <td>New York</td>
            <td>65</td>
            <td>2008/09/26</td>
            <td>$645,750</td>
        </tr>
        <tr>
            <td>FFFFFFFFFFFFFFFFFF</td>
            <td>Support Engineer</td>
            <td>Singapore</td>
            <td>64</td>
            <td>2011/02/03</td>
            <td>$234,500</td>
        </tr>
        <tr>
            <td>GGGGGGGGGGGGGGGGGGG</td>
            <td>Software Engineer</td>
            <td>London</td>
            <td>38</td>
            <td>2011/05/03</td>
            <td>$163,500</td>
        </tr>
        <tr>
            <td>HHHHHHHHHHHHH Yamamoto</td>
            <td>Support Engineer</td>
            <td>Tokyo</td>
            <td>37</td>
            <td>2009/08/19</td>
            <td>$139,575</td>
        </tr>
        <tr>
            <td>IIIIIIIIIIIIII Walton</td>
            <td>Developer</td>
            <td>New York</td>
            <td>61</td>
            <td>2013/08/11</td>
            <td>$98,540</td>
        </tr>
        <tr>
            <td>JJJJJJJJJJJJJJJ Camacho</td>
            <td>Support Engineer</td>
            <td>San Francisco</td>
            <td>47</td>
            <td>2009/07/07</td>
            <td>$87,500</td>
        </tr>
        <tr>
            <td>KKKKKKKKKKKKKKKKK Baldwin</td>
            <td>Data Coordinator</td>
            <td>Singapore</td>
            <td>64</td>
            <td>2012/04/09</td>
            <td>$138,575</td>
        </tr>
        <tr>
            <td>LLLLLLLLLLLLLLL Frank</td>
            <td>Software Engineer</td>
            <td>New York</td>
            <td>63</td>
            <td>2010/01/04</td>
            <td>$125,250</td>
        </tr>
        <tr>
            <td>MMMMMMMMMMMMMMM Serrano</td>
            <td>Software Engineer</td>
            <td>San Francisco</td>
            <td>56</td>
            <td>2012/06/01</td>
            <td>$115,000</td>
        </tr>
        <tr>
            <td>NNNNNNNNNNNNNNNN Acosta</td>
            <td>Junior Javascript Developer</td>
            <td>Edinburgh</td>
            <td>43</td>
            <td>2013/02/01</td>
            <td>$75,650</td>
        </tr>
        <tr>
            <td>OOOOOOOOOOOOO Stevens</td>
            <td>Sales Assistant</td>
            <td>New York</td>
            <td>46</td>
            <td>2011/12/06</td>
            <td>$145,600</td>
        </tr>
        <tr>
            <td>PPPPPPPPPPPPP Butler</td>
            <td>Regional Director</td>
            <td>London</td>
            <td>47</td>
            <td>2011/03/21</td>
            <td>$356,250</td>
        </tr>
        <tr>
            <td>QQQQQQQQQQQQ Greer</td>
            <td>Systems Administrator</td>
            <td>London</td>
            <td>21</td>
            <td>2009/02/27</td>
            <td>$103,500</td>
        </tr>
        <tr>
            <td>RRRRRRRRRRRR Alexander</td>
            <td>Developer</td>
            <td>San Francisco</td>
            <td>30</td>
            <td>2010/07/14</td>
            <td>$86,500</td>
        </tr>
        <tr>
            <td>SSSSSSSSSSSSSSSS Decker</td>
            <td>Regional Director</td>
            <td>Edinburgh</td>
            <td>51</td>
            <td>2008/11/13</td>
            <td>$183,000</td>
        </tr>
        <tr>
            <td>TTTTTTTTTTTTTTTT Bruce</td>
            <td>Javascript Developer</td>
            <td>Singapore</td>
            <td>29</td>
            <td>2011/06/27</td>
            <td>$183,000</td>
        </tr>
        <tr>
            <td>UUUUUUUUUU Snider</td>
            <td>Customer Support</td>
            <td>New York</td>
            <td>27</td>
            <td>2011/01/25</td>
            <td>$112,000</td>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
 
$('#example').dataTable({
          "bPaginate": true,
          "bLengthChange": true,
          "bFilter": true,
          "bSort": true,
          "bInfo": true,
          "bAutoWidth": true
        });


} );


</script>
</body>
</html>

How to fix any HTML tag at any position

Problem:

How to fix any HTML tag at any position for ex: fix a div at right bottom corner?

Solution:

Use style z-index, bottom, right attribute

Example:

<div id="loading_msg" style="position: fixed; z-index: 99;  bottom: 15px; right: 10px;
    display:; background-color:#CC99FF">Loading now Please wait...</div>

Scrolling paging in PHP

Problem:

Database paging without paging page number.  This is same as Facebook and Tumblr like paging.

Solution:

By using Ajax you can achieve that like scroll paging.

Example:

Use below code. Assuming 1 to 10th records already showing.

index.php
<script type="text/javascript" src="jquery-1.6.js"></script>
<div id="mydiv">
<p>Database paging </p><p>without paging</p><p>page number</p><p>This is same as Facebook</p><p>and Tumblr.</p><p>like paging.</p><p>Assuming 1 to 10th records already showing.</p> <p>Next 11th to end of records will show when scroll page.</p>

<p>1 record</p><p>2 record</p><p>3 record</p><p>4 record</p><p>5 record</p><p>6 record</p><p>7 record</p><p>8 record</p><p>9 record</p><p>10 record</p>   </div>

<a id="loading_img" style="position:fixed; z-index: 99;bottom: 15px; right: 10px; display:none;">Loading... <img src="ajax-loader.gif" /></a>

<script type="text/javascript">
var page = 1;
$(window).scroll(function () {
currentX = $(window).scrollTop();
if  ($(window).scrollTop() == $(document).height() - $(window).height()){
$('a#loading_img').show('fast');
$.get('mydb.php?page=' + page, function(data) {
$('#mydiv').append(data);
$('a#loading_img').hide('fast');
}
);
page++;
}
});
</script>



mydb.php

<?php
$mysqli = new mysqli('localhost', 'root', '','mydb');
$pg=$_GET['page'];
$pg=$pg*10;
$sql='SELECT *FROM book_wise_test ORDER BY book_wise_test_id LIMIT '.$pg .', 10';
$result  = $mysqli->query($sql);
while($row = $result->fetch_assoc()) {
$book_wise_test_id=$row['book_wise_test_id'];
$book_nm=$row['book_nm'];
echo $book_wise_test_id.'======'.$book_nm.'<br/><br/>';
}
?>

Message: Undefined variable: 0 in CodeIgniter PHP

Problem:

Sometime while working with CodeIngiter / PHP you may encounter "Undefined variable: 0" error.
It surprise to that is "0" (Zero) could be a variable!

Solution:

This "Undefined variable: 0" error come when you use double dollar sign in variable. so remove one dollar ($) sign from variable and error will gone.

Example:

See the below code, specially in red color, it having $$ sign:

$data = array( 'u_login' => $row->u_login,
                        'user_type_id' => $user_type_id,
'user_id'=>$row->user_id,
'transporter_id'=>$transporter_id,
'limit_cr'=>$limit_cr,
'u_c_date'=>$row->u_c_date,
'total_trucks'=>$total_trucks,
'total_liter'=>$total_liter,
'pump_id'=> $$pump_id
                        );

jut remove one $ sign.

How to convert eps file to jpg file

Problem:

How to convert .eps file to .jpg file

Solution:

It is simple, use ImageMagick and below java code. if you expert in PHP or .Net then you can easily convert it same as me.

Example:

import="java.util.*"%>  
import="java.io.*"%>
 
try
    {
        Runtime runTime = Runtime.getRuntime();
        Process process = runTime.exec ("C:/Program Files/ImageMagick-6.5.4-Q16/convert.exe c:/Art1.eps c:/art1.jpg");
        //InputStream inputStream = process.getInputStream();
        //InputStreamReader   inputStreamReader = new InputStreamReader (inputStream);
        //BufferedReader bufferedReader = new BufferedReader(
inputStreamReader);
        ///String line = null;
        //while ( (line = bufferedReader.readLine()) != null )
        //    System.out.println(line);
        int exitVal = process.waitFor();
        System.out.println ("Process exitValue:  " + exitVal );
    }
    catch (Throwable t)
    {
        t.printStackTrace();
    }

How to load JavaScript file async in Magento

Problem:

By async loading JavaScript it will boost up your site, so how to load JavaScript file async in Magento.  In Magento there are two methods to load JavaScript .
1- By addItem
2-By addJs

Solution:

By using async option in <params>async</params> script tag you can load it.

Example:

Open your local.xml file it will be in the "app\design\frontend\default\YOUR-THEME-NAME\layout" folder.

1- By addItem
<action method="addItem">
    <type>skin_js</type>
    <name>js/jquery.mousewheel.min.js</name>
   <params>async</params>
</action>


2-By addJs
<action method="addJs">
     <script>scriptaculous/effects.js</script>
     <params>async</params>
</action>