Saturday, September 27, 2008

Only selected are print through javascript

Hi friends

If you want to take only selected area print out not whole web page then use the following guidelines and enjoy :-

Take a print are in a single div and any event like onclick , onblur what ever you eant call the below javascript function -

/* function fnPrintArea()
var DocumentContainer = document.getElementById('print_table_div_id');
var WindowObject ='', "printarea",


Multiple date selection javascript calendar

Hi all There is a link please vistite for multiple date selection calendar in javascript

If you face some issue(not sure may be , because i am facing when i have implement this) on there like

calender not show in IE7 properly ?


you want to disabler older date or range of dates ?


Single click problem ?

then use the same site forum for all your question passionaly and still you are face problem then fill free comment here i will answer all your question as soon as possible.

how Same session Id in http:// and https://

If you have the condition like that you want same session id in the http and HTTPS prtocal the simple one line solution:-

Just make it one .htaccess file and upload in your server top root directory

and write the .htaccess like this -


php_value session.cookie_domain ""


so now save the .htaccess file and upload on the server and check the cookie of your web browser , when you redirect from http to https or vicecersa your session id remain same.

Or any question regarding this feel free comment here.....

Tuesday, September 9, 2008

phpcamppune08 - PHP camp at pune 2008

phpcamp pune 2008: A gathering of php enthusiast

PHPCamp is a ‘ad-hoc gathering’ for PHP community. It similar to barcamp , but more focused towards PHP based web application development. This means that anyone can come to PHPCamp and participate.

Event Details

Date: 20th September 2008 (saturday) .

Time: 10:00am to 6:00pm (Whole day event) .

To register for PHPCamp register yourself at

To know more join phpcamp on google groups.

Saturday, August 30, 2008

PHP with smarty template engine installation

PHP with smarty installation is so easy....

just download the stable version of smarty package and unzip the folder and rename folder name "smarty"

and now you create four directory in your application folder

1) config
2) templates_c
3) templates
4) cache

and just create one php file and here just specify the pathe of smaty.connect.php file and all four directory path

like the pls see example below

// put full path to Smarty.class.php
$smarty = new Smarty();

$smarty->template_dir = '/web/';
$smarty->compile_dir = '/web/';
$smarty->cache_dir = '/web/';
$smarty->config_dir = '/web/';

$smarty->assign('name', 'MANISH');

now include above php file anywhere and use the smartyy template magic.

any question then pls cooment here....i will give u the answer...thanks

Connect Mysql database in php

PHP main target is to make possible build dynamic web sites.
This possibility is available by using some database system to store information and manipulate them, when system and user needs it.
On PHP a large number of database systems come by default embbed as libraries.
On this article we will learn how to use one of the most used on data handling - MySQL.
MySQL can be installed easly, by downloading EasyPHP.
This application installs Mysql on a web based version, it means that you can manage all database processes on your browser.
It allows to create databases, and tables, edit fields , backup tables system database and a large option of new features.
To access the interface that allows you to create database click with the right button of mouse on tray icon "Administration".
Right next click


it will open the window where you must the name of your database and next it will ask for your table name.

Check how many fields you need on your table and build it.

Now the database and table are created let´s configure the conection to the mysql server using PHP.
Remember that server is configured with an default username and password.
You can make secure by changing it at your choice.

Follows the PHP code generated to build the table

CREATE TABLE `admin` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(40) NOT NULL,
`password` varchar(16) NOT NULL,

and now time to connect with php this table.....

$con = mysql_connect("localhost","database usernam","password");
if (!$con)
die('Could not connect: ' . mysql_error());

Saturday, July 26, 2008

Major Changes betwwen PHP4 and PHP5 XML support

Two extensions have changed.The XSLT extension present in PHP4 is not the XSL extension in PHP 5.Additionally, the XML-DOM extension in PHP 4 is not the DOM extensionis PHP 5. What this means is that the syntax of the functions in theseextensions have changed but the purpose of the extensions has notchanged.

PHP 5 Object Model

PHP 5 there is a new Object Model. PHP's handling of objects has been completely rewritten, allowing for better performance and more features. In previous versions of PHP, objects were handled like primitive types (for instance integers and strings). The drawback of this method was that semantically the whole object was copied when a variable was assigned, or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not by value (one can think of a handle as an object's identifier).Many PHP programmers aren't even aware of the copying quirks of the old object model and, therefore, the majority of PHP applications will work out of the box, or with very few modificationsThe new Object Model is documented at the

PHP 5 array types

Types of arrays:

Numerically indexed arrays
Associative arrays
Multidimensional arrays
Sorting arrays

how write javascript code into PHP code ?

You just echo / print the javascript like you would do with html, like:

echo and then start script tag here

write the code echo alert();

echo and script tag end here

PHP stand for?

PHP is short for "PHP: Hypertext Preprocessor".

Friday, July 25, 2008

include path settings , without access to php.ini

If you are hosting on a Linux server you may (Depending on your host) be able to use .htaccess this file must be in the root of the web directory.The format is along the lines of (For PHP4 Module):-php_value include_path .:/path/that/you/want/to/usephp_value magic_quotes_gpc "off"php_value track_errors "on"

Pear Package PHP Description

What is PEAR?
how install the PEAR?
Quoted from PEAR's homepage at"PEAR is a framework and distribution system for reusable PHP components."So what can PEAR be used for?In short it's will be a full framework for building php applications, meaning there will be classes for most purposes you can use instead of writing your own code. If you are a current/former perl programmer PEAR has simalaraties to perl's CPAN framework. For more information about PEAR and how you get started look at the following articles:
The official PEAR homepage is found here

Saturday, June 7, 2008

how to convert PHP array in to PHP object ?

$a = $array("a"=> 1, "b"=> 2);

now type cast array in to object...

$arrayObj = (object)$a;

now u able to use like object and method.....

echo $arrayObj->a; // output 1
echo $arrayObj->b;// output 2

but only work with key as a string.....not work with indexed array.

How to get current PHP..?????

just simple

use a inbuilt PHP date() function and pass the time() function as a parameter....


echo date("y/m/d",time());

first parameter is date format.

and second is PHP inbuilt time() function.

List of Output Control Functions in PHP 5

o flush — Flush the output buffer
o ob_clean — Clean (erase) the output buffer
o ob_end_clean — Clean (erase) the output buffer and turn off output buffering
o ob_end_flush — Flush (send) the output buffer and turn off output buffering
o ob_flush — Flush (send) the output buffer
o ob_get_clean — Get current buffer contents and delete current output buffer
o ob_get_contents — Return the contents of the output buffer
o ob_get_flush — Flush the output buffer, return it as a string and turn off output

o ob_get_length — Return the length of the output buffer
o ob_get_level — Return the nesting level of the output buffering mechanism
o ob_get_status — Get status of output buffers
o ob_gzhandler — ob_start callback function to gzip output buffer
o ob_implicit_flush — Turn implicit flush on/off
o ob_list_handlers — List all output handlers in use
o ob_start — Turn on output buffering
o output_add_rewrite_var — Add URL rewriter values
o output_reset_rewrite_vars — Reset URL rewriter values

List of Predefined variables in PHP 5 and PHP 4

PHP5 and PHP4 provides a large number of predefined variables to all scripts.

* Superglobals — Superglobals are built-in variables that are always available in all scopes
* $GLOBALS — References all variables available in global scope
* $_SERVER — Server and execution environment information
* $_GET — HTTP GET variables
* $_POST — HTTP POST variables
* $_FILES — HTTP File Upload variables
* $_REQUEST — HTTP Request variables
* $_SESSION — Session variables
* $_ENV — Environment variables
* $_COOKIE — HTTP Cookies
* $php_errormsg — The previous error message
* $http_response_header — HTTP response headers
* $argc — The number of arguments passed to script
* $argv — Array of arguments passed to script

PHP5 Encapsulation Surprises to you ..........

In PHP5, unlike Java or C++, $this has to be explicitly used to refer to variables within a


The value of $this is determined by the context in which it is called. In certain situations

$this may actually refer to the invoking class rather then the current class. This breaks object


$this pseudo-variable is not defined if the method in which it is located is called statically

with an exception as noted below.

$this is defined if a method is called statically from within another object. In this case, the

value of $this is that of the calling object.

The following example from PHP manual will clarify this:

$b = new B();


$this is defined (a)
$this is not defined.
$this is defined (b)
$this is not defined.

Thursday, February 28, 2008

How do I send mails with PHP?

PHP has a function called mail for that purpose, example (from

mail("", "the subject", $message,
"From: webmaster@$SERVER_NAME\r\n"
."Reply-To: webmaster@$SERVER_NAME\r\n"
."X-Mailer: PHP/" . phpversion());

For more information about the function look here:

I have lost my MySQL root password, how can I get in?

If you have forgotten the root user password for MySQL, you can restore it with the following procedure:

Take down the mysqld server by sending a kill (not kill -9) to the mysqld server.

The pid is stored in a .pid file, which is normally in the MySQL database directory:
kill `cat /mysql-data-directory/`

You must be either the Unix root user or the same user the server runs as to do this.

Restart mysqld with the --skip-grant-tables option.

Connect to the mysqld server with mysql -h hostname mysql and change the password with a GRANT command.

See section 7.35 GRANT and REVOKE Syntax

You can also do this with mysqladmin -h hostname -u user password 'new password'

Load the privilege tables with: mysqladmin -h hostname flush-privileges or with the SQL command FLUSH PRIVILEGES.

Note that after you started mysqld with --skip-grant-tables, any usage of GRANT commands will give you an Unknown command error until you have executed FLUSH PRIVILEGES.