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.

Wednesday, October 5, 2011

Professional PHP6 (Wrox Programmer to Programmer)



Product Description
Publishing in tandem with the long-awaited release of PHP 6, this book reveals the inside scoop for pushing the limits of how to maximize the full feature set of PHP 6. You?ll learn how to use PHP 6 in the larger scheme of enterprise-class software development and practical examples and behind-the-scenes information will improve your skills for designing and building better large-scale, high-performance platforms using PHP 6.

From the Back Cover

Each new version of PHP proves to be easily accessible and requires only a small learning curve. In no time at all, you can put together a simple yet dynamic Web site. This book goes beyond just showing you how to create a quick and uncomplicated site; it helps you deliver better quality software in a shorter amount of time using PHP6.

To put your working knowledge of PHP to use, the authors dive right in with the recent launch of version 6, while highlighting the differences between PHP6 and earlier versions. You'll begin with the fundamentals of professional development and a review of basic object oriented programming (OOP) concepts, before moving on to more advanced development techniques. You'll eventually put all that you've learned into practice and build an application from the ground up using a model-view controller (MVC) framework. Ultimately, you'll discover how to unleash the power of PHP6 and push it to its limits.


PHP5 and MySQL bible



About the Book
This comprehensive tutorial and reference covers all the basics of PHP 5, a popular open source Web scripting language, and MySQL 4.012, the most popular open source database engine Explores why users need PHP and MySQL, how to get started, how to add PHP to HTML, and how to connect HTML Web pages to MySQL Offers an extensive tutorial for developing applications with PHP and MySQL Includes coverage of how to install, administer, and design MySQL databases independently of PHP; exception and error handling; debugging techniques; PostgreSQL database system; and PEAR database functions The authors provide unique case studies of how and where to use PHP drawn from their own extensive Web experience 


Learning PHP Data Objects



Publisher: Packt Publishing | ISBN: 1847192661 | edition 2007 | PDF | 185 pages | 2.7 mb
BOOK DESCRIPTION:
In Detail

PDO is lighter, faster, and more powerful than existing PHP data abstraction interfaces. PDO is a common interface to different databases that must be used with a database-specific PDO driver to access a particular database server: the PDO extension does not provide a database abstraction by itself; it doesn’t rewrite SQL, emulate missing database features, or perform any database functions using by itself. It performs the same role as other classic database abstraction layers such as ODBC and JDBC: it’s a query abstraction layer that abstracts the mechanism for accessing a database and manipulating the returned records; each database driver that implements the PDO interface can also expose database-specific features as regular extension functions. ¬ PDO ships with PHP 5.1, and is available as an extension for PHP 5.0; it requires the new object-oriented features of PHP 5, and cannot run with earlier versions of PHP.
This book will teach you how to use the PDO, including its advanced features. Readers need to be aware of the basics of data abstraction and should be familiar with PHP.
What you will learn from this book?

This book covers:
An overview of the technology
Getting started with PDO
Error handling, prepared statements, and handling rowsets
Advanced features, like getting column metadata and setting connection parameters with examples
Approach
This book describes the topic first and then gives step-by-step instructions on how to go about a particular example.
Who this book is written for?

PHP developers who need to use PDO for data abstraction.
BOOK DETAILS:
Paperback: 188 pages
Publisher: Packt Publishing (August 30, 2007)
Language: English
ISBN-10: 1847192661
ISBN-13: 978-1847192660