This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions..

Tuesday, April 23, 2013

insert multiple row in database using php-mysql


<?php include('config.php');

extract($_GET);
extract($_POST);

 $gname = explode(',',$gname);
 $gid = explode(',',$gid);
 $gvalue = explode(',',$gvalue);
 $uname = $nuname;
 $address = $address;
 $mnumber = $mnumber;
 $moperator = $moperator;
 $mail = $email;
 $uid = $uid;
 $fname = $fname;
 $totalpoints = $totalpoints;
 $checkPoints=$checkPoints;
 $sub_date = date("Y-m-d");
 $updatepoint = $checkPoints-$totalpoints;

?>

<?php
$cnt = count($gname);
$cnt2 = count($gvalue);

if ($cnt > 0 && $cnt == $cnt2) {
    $insertArr = array();
    for ($i=0; $i<$cnt; $i++) {

   
 $insertArr[] = "('','" . mysql_real_escape_string($gid[$i]) ."','$uid','" . mysql_real_escape_string($gname[$i]) . "','" . mysql_real_escape_string($gvalue[$i]) ."','$fname','$uname','$sub_date','','$mnumber','$address','$moperator','$mail','','','1','','','','','')";
   
   
//        $insertArr[] = "('','" . mysql_real_escape_string($gname[$i]) . "', '" . mysql_real_escape_string($gvalue[$i]) ."','" . mysql_real_escape_string($gid[$i]) ."','" . mysql_real_escape_string($uname)."','" . mysql_real_escape_string($uname)."')";
    }


$query = "INSERT INTO table_name VALUES ". implode(", ", $insertArr);

if (mysql_query($query))
  {
  include('pointredeam.php');
  }
else
  {
  echo "there was some error please try later";
  }

//echo "query = $query";

}
header('location:index.php');
?>

Monday, April 15, 2013

Image resizeing using php and store in a particular folder

<?php

function resizeImage($source_image, $target_image, $crop_area)
{
    // get image name with image extension     $source_file_name = basename($source_image);

    $source_image_type = substr($source_file_name, -3, 3);
   
    // create an image resource from the source image      switch(strtolower($source_image_type))
    {
        case 'jpg':
            $original_image = imagecreatefromjpeg($source_image);
            break;
           
        case 'gif':
            $original_image = imagecreatefromgif($source_image);
            break;

        case 'png':
            $original_image = imagecreatefrompng($source_image);
            break;   
       
        default:
            trigger_error('cropImage(): Invalid source image type', E_USER_ERROR);
            return false;
    }
   
    // create a blank image having the same width and height as the crop area
    // this will be our cropped image
    $cropped_image = imagecreatetruecolor($crop_area['width'], $crop_area['height']);   
    // copy the crop area from the source image to the blank image created above    imagecopy($cropped_image, $original_image, 0, 0, $crop_area['left'], $crop_area['top'],
              $crop_area['width'], $crop_area['height']);
    
    // detect target image type from extension   $target_file_name = basename($target_image);
    $target_image_type = substr($target_file_name, -3, 3);
   
    // save the cropped image to disk    switch(strtolower($target_image_type))
    {
        case 'jpg':
            imagejpeg($cropped_image, $target_image, 100);
            break;
           
        case 'gif':
            imagegif($cropped_image, $target_image);
            break;

        case 'png':
            imagepng($cropped_image, $target_image, 0);
            break;   
       
        default:
            trigger_error('cropImage(): Invalid target image type', E_USER_ERROR);
            imagedestroy($cropped_image);
            imagedestroy($original_image);
            return false;
    }
   
    // release image resources    imagedestroy($cropped_image);
    imagedestroy($original_image);
   
    return true;
}
?>


<?php 
// using the function to resize an image
$source_image = 'image.jpg';


$newname = basename($source_image);


//image location for to store image
$target_image = 'thumbs/'.$newname;


//image resource for image on screen
$newimage_path = 'thumbs/'.$newname;

$crop_area = array('top' => 100, 'left' => 100, 'height' => 100, 'width' => 100);

resizeImage($source_image, $target_image, $crop_area);

echo '<img src="'.$newimage_path.'" ><p>';
 

?>

Call A Jquery function from outside of php/html file

Step 1:

Create a jquery function in a js file and save this with test.js name you can use your desired name as you want.

Example:


(function($){
  tile = function() {
alert("see it work")
  };
})(jQuery);
 

 Step 2:

create a php or html file at where you want to call function which is in test.js.

Example:

<!DOCTYPE html>
<html>
<head>
<title>HyperStudio Timeline</title>
 <script type="text/javascript" src="jquery-1.3.2.js"></script>
  <script type="text/javascript" src="test.js"></script>

<!--Here I used my function which i earlier defined in test.js file-->  <script type="text/javascript">
   $(document).ready(function(){
      tile();
    });
</script>
</head>
<body>
</body>
</html>


this is a simple way to call a jquery function from outsider js file.

Note: don't forget to include jquery-1.3.2.js file 'or' higher jquery file without this file these will not work.

Memcached Basic Tutorial


What is Memcached?

Memcached is a very powerful memory object caching system. It is used to speed up dynamic web applications by alleviating database load.

Installation of memcached on Ubuntu 12.04 is very simple. On the terminal, let's typing following command:

sudo apt-get install memcached
sudo apt-get install php5-memcache
sudo /etc/init.d/apache2 restart

To test it by entering:

telent localhost 11211

if memcached is installed successful, the above command will return:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

The official site of Memcached is here.