Monday, December 7, 2009

Downloading Files From MySQL Database

When we upload a file to database we also save the file type and length. These were not needed for uploading the files but is needed for downloading the files from the database.

The download page list the file names stored in database. The names are printed as a url. The url would look like download.php?id=3.

nclude 'library/config.php';
include 'library/opendb.php';

$query = "SELECT id, name FROM upload";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "Database is empty
";
}
else
{
while(list($id, $name) = mysql_fetch_array($result))
{
?>








When you click the download link, the $_GET['id'] will be set. We can use this id to identify which files to get from the database. Below is the code for downloading files from MySQL Database.

Example :
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database

include 'library/config.php';
include 'library/opendb.php';

$id = $_GET['id'];
$query = "SELECT name, type, size, content " .
"FROM upload WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
echo $content;

include 'library/closedb.php';
exit;
}

Before sending the file content using echo first we need to set several headers. They are :

  1. header("Content-length: $size")
    This header tells the browser how large the file is. Some browser need it to be able to download the file properly. Anyway it's a good manner telling how big the file is. That way anyone who download the file can predict how long the download will take.
  2. header("Content-type: $type")
    This header tells the browser what kind of file it tries to download.
  3. header("Content-Disposition: attachment; filename=$name");
    Tells the browser to save this downloaded file under the specified name. If you don't send this header the browser will try to save the file using the script's name (download.php).

After sending the file the script stops executing by calling exit.

error---Cannot modify header information - headers already sent

This error happens because some data was already sent before we send the header. As for the error message above it happens because i "accidentally" add one space right after the PHP closing tag ( ?> ) in config.php file. So if you see this error message when you're sending a header just make sure you don't have any data sent before calling header().

upload phto

1.

2. Photo
3.
4.
5.


$max_file)) {
$error= "ONLY jpeg images under 1MB are accepted for upload";
}
}else{
$error= "Select a jpeg image for upload";
}
//Everything is ok, so we can upload the image.
if (strlen($error)==0){

if (isset($_FILES["image"]["name"])){

move_uploaded_file($userfile_tmp, $large_image_location);
chmod ($large_image_location, 0777);

$width = getWidth($large_image_location);
$height = getHeight($large_image_location);
//Scale the image if it is greater than the width set above
if ($width > $max_width){
$scale = $max_width/$width;
$uploaded = resizeImage($large_image_location,$width,$height,$scale);
}else{
$scale = 1;
$uploaded = resizeImage($large_image_location,$width,$height,$scale);
}
//Delete the thumbnail file so the user can create a new one
if (file_exists($thumb_image_location)) {
unlink($thumb_image_location);
}
}
//Refresh the page to show the new uploaded image
header("location:".$_SERVER["PHP_SELF"]);
exit();
}
}

Pagination in php

$sql = "SELECT COUNT(*) FROM users";
$result = mysql_query($sql) OR die(mysql_error());
$r = mysql_fetch_row($result);
$numrows = $r[0];

// number of rows to show per page
$rowsperpage = 20;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);
// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
// cast var as int
$currentpage = (int) $_GET['currentpage'];
} else {
// default page num
$currentpage = 1;
} // end if

// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < currentpage =" 1;" offset =" ($currentpage" term =" $_GET['artist'];" artist =" mysql_real_escape_string($_GET['artist']);" href="http://www.blogger.com/%5C%22admin.php%5C%22">Return to admin section!


";

echo "
Uploads:
";

$sql = "SELECT * FROM users LIMIT $offset, $rowsperpage";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
$result=mysql_query($sql);
while ($list = mysql_fetch_array($result))
{
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";


}
echo "";
echo "
idnamegenderdobemailphoneusernamestatusdeleteedit
",$list['id'],"",$list['name'],"", $list['gender'],"",$list['dob'],"",$list['email'],"",$list['phone'],"",$list['username'],"",$list['status'],"", "";
echo "
","\">Deleteuser","", "";
echo "
","\">updatestatus
","
";
echo "

";
$range = 3;

// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << href="http://www.blogger.com/%7B$_SERVER%5B" php_self="" currentpage="1'"><< "; // get previous page num $prevpage = $currentpage - 1; // show < href="http://www.blogger.com/%7B$_SERVER%5B" php_self="" currentpage="$prevpage'">< "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [$x] ";
// if not current page...
} else {
// make it a link
echo " $x ";
} // end else
} // end if
} // end for

// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " NEXT PAGE ";
// echo forward link for lastpage
echo " a href="http://www.blogger.com/%7B$_SERVER%5B" php_self="" currentpage="$totalpages'"> LAST PAGE ";
} // end if
echo "
";

email me to get the code of this coding

rawatsingharun@gmail.com

Friday, November 20, 2009

php flash upload

Adding file upload functionality to an application

The following procedure shows you how to build an application that lets you upload image files to a server. The application lets users select an image on their hard disks to upload and then send it to a server. The image that they upload then appears in the SWF file that they used to upload the image.

Following the example that builds the Flash application is an example that details the server-side code. Remember that image files are restricted in size: you can only upload images that are 200K or smaller.
To build a FLA application using the FileReference API:

1. Create a new Flash document and save it as fileref.fla.
2. Open the Components panel, and then drag a ScrollPane component onto the Stage and give it an instance name of imagePane. (The ScrollPane instance is sized and repositioned using ActionScript in a later step.)
3. Drag a Button component onto the Stage and give it an instance name of uploadBtn.
4. Drag two Label components onto the Stage and give them instance names of imageLbl and statusLbl.
5. Drag a ComboBox component onto the Stage and give it an instance name of imagesCb.
6. Drag a TextArea component onto the Stage and give it an instance name of statusArea.
7. Create a new movie clip symbol on the Stage, and open the symbol for editing (double-click the instance to open it in symbol-editing mode).
8. Create a new static text field inside the movie clip, and then add the following text:

The file that you have tried to download is not on the server.

In the final application, this warning might appear for one of the following reasons, among others:
* The image was deleted from the queue on the server as other images were uploaded.
* The server did not copy the image because the file size exceeded 200K.
* The type of file was not a valid JPEG, GIF, or PNG file.

NOTE





The width of the text field should be less than the width of the ScrollPane instance (400 pixels); otherwise users have to scroll horizontally to view the error message
9. Right-click the symbol in the Library and select Linkage from the context menu.
10. Select the Export for ActionScript and Export in First Frame check boxes, and type Message into the Identifier text box. Click OK.
11. Add the following ActionScript to Frame 1 of the Timeline:

NOTE





The code comments include details about the functionality. A code overview follows this example.

import flash.net.FileReference;

imagePane.setSize(400, 350);
imagePane.move(75, 25);
uploadBtn.move(75, 390);
uploadBtn.label = "Upload Image";
imageLbl.move(75, 430);
imageLbl.text = "Select Image";
statusLbl.move(210, 390);
statusLbl.text = "Status";
imagesCb.move(75, 450);
statusArea.setSize(250, 100);
statusArea.move(210, 410);

/* The listener object listens for FileReference events. */
var listener:Object = new Object();

/* When the user selects a file, the onSelect() method is called, and passed a reference to the FileReference object. */
listener.onSelect = function(selectedFile:FileReference):Void {
/* Update the TextArea to notify the user that Flash is attempting to upload the image. */
statusArea.text += "Attempting to upload " + selectedFile.name + "\n";
/* Upload the file to the PHP script on the server. */
selectedFile.upload("http://www.helpexamples.com/flash/file_io/uploadFile.php");
};

/* When the file begins to upload, the onOpen() method is called, so notify the user that the file is starting to upload. */
listener.onOpen = function(selectedFile:FileReference):Void {
statusArea.text += "Opening " + selectedFile.name + "\n";
};

/* When the file has uploaded, the onComplete() method is called. */
listener.onComplete = function(selectedFile:FileReference):Void {
/* Notify the user that Flash is starting to download the image. */
statusArea.text += "Downloading " + selectedFile.name + " to player\n";
/* Add the image to the ComboBox component. */
imagesCb.addItem(selectedFile.name);
/* Set the selected index of the ComboBox to that of the most recently added image. */
imagesCb.selectedIndex = imagesCb.length - 1;
/* Call the custom downloadImage() function. */
downloadImage();
};

var imageFile:FileReference = new FileReference();
imageFile.addListener(listener);

imagePane.addEventListener("complete", imageDownloaded);
imagesCb.addEventListener("change", downloadImage);
uploadBtn.addEventListener("click", uploadImage);

/* If the image does not download, the event object's total property will equal -1. In that case, display a message to the user. */
function imageDownloaded(event:Object):Void {
if (event.total == -1) {
imagePane.contentPath = "Message";
}
}

/* When the user selects an image from the ComboBox, or when the downloadImage() function is called directly from the listener.onComplete() method, the downloadImage() function sets the contentPath of the ScrollPane in order to start downloading the image to the player. */
function downloadImage(event:Object):Void {
imagePane.contentPath = "http://www.helpexamples.com/flash/file_io/images/" + imagesCb.value;
}

/* When the user clicks the button, Flash calls the uploadImage() function, and it opens a file browser dialog box. */
function uploadImage(event:Object):Void {
imageFile.browse([{description: "Image Files", extension: "*.jpg;*.gif;*.png"}]);
}

This ActionScript code first imports the FileReference class and initializes, positions, and resizes each of the components on the Stage. Next, a listener object is defined, and three event handlers are defined: onSelect, onOpen, and onComplete. The listener object is then added to a new FileReference object named imageFile. Next, event listeners are added to the imagePane ScrollPane instance, imagesCb ComboBox instance, and uploadBtn Button instance. Each of the event listener functions is defined in the code that follows this section of code.

The first function, imageDownloaded(), checks to see if the amount of total bytes for the downloaded images is -1, and if so, it sets the contentPath for the ScrollPane instance to the movie clip with the linkage identifier of Message, which you created in a previous step. The second function, downloadImage(), attempts to download the recently uploaded image into the ScrollPane instance. When the image has downloaded, the imageDownloaded() function defined earlier is triggered and checks to see whether the image successfully downloaded. The final function, uploadImage(), opens a file browser dialog box, which filters all JPEG, GIF, and PNG images.
12. Save your changes to the document.
13. Select File > Publish settings and then select the Formats tab, and make sure that Flash and HTML are both selected.
14. (Optional) In the Publish Settings dialog box, select the Flash tab, and then select Access Network Only from the Local Playback Security pop-up menu.

If you complete this step, you won't run into security restrictions if you test your document in a local browser.
15. In the Publish Settings dialog box, click Publish to create the HTML and SWF files.

When you're finished, go on to the next procedure, in which you create the container for the SWF file.

For a sample source file for this example, FileUpload.fla, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download the Samples zip file and navigate to the ActionScript2.0/FileUpload folder to access this sample.

The following procedure requires that PHP is installed on your web server and that you have write permissions to subfolders named images and temporary. You need to first complete the previous procedure, or use the finished SWF file available in the previously noted folders.
To create a server-side script for the image upload application:

1. Create a new PHP document using a text editor such as Dreamweaver or Notepad.
2. Add the following PHP code to the document. (A code overview follows this script.)

$MAXIMUM_FILE_COUNT) {
$files_to_delete = array_splice($files, 0, count($files) - $MAXIMUM_FILE_COUNT);
for ($i = 0; $i <>

This PHP code first defines two constant variables: $MAXIMUM_FILESIZE and $MAXIMUM_FILE_COUNT. These variables dictate the maximum size (in kilobytes) of an image being uploaded to the server (200KB), as well as how many recently uploaded files can be kept in the images folder (10). If the file size of the image currently being uploaded is less than or equal to the value of $MAXIMUM_FILESIZE, the image is moved to the temporary folder.

Next, the file type of the uploaded file is checked to ensure that the image is a JPEG, GIF, or PNG. If the image is a compatible image type, the image is copied from the temporary folder to the images folder. If the uploaded file wasn't one of the allowed image types, it is deleted from the file system.

Next, a directory listing of the image folder is created and looped over using a while loop. Each file in the images folder is added to an array and then sorted. If the current number of files in the images folder is greater than the value of $MAXIMUM_FILE_COUNT, files are deleted until there are only $MAXIMUM_FILE_COUNT images remaining. This prevents the images folder from growing to an unmanageable size, as there can be only 10 images in the folder at one time, and each image can only be 200KB or smaller (or roughly 2 MB of images at any time).
3. Save your changes to the PHP document.
4. Upload the SWF, HTML, and PHP files to your web server.
5. View the remote HTML document in a web browser, and click the Upload Image button in the SWF file.
6. Locate an image file on your hard disk and select Open from the dialog box.

php upload with flash

create a blank flash document in flash cs4.

2) create a folder named with “flexScript” and copy and paste the below code to a new actionscript file and save the file into “flexScript” folder with the name “uploadImage”.

3) put a button component on the stage and put a instance name as “upload_Image”;

4) set the document class as “flexScript.uploadImage”; and run the application and check the magic;
view source
print?
01 package flexScript {
02 import flash.display.Sprite;
03 import flash.events.MouseEvent;
04 import flash.net.*;
05 import flash.display.*;
06 import flash.events.*;
07 import flash.utils.ByteArray;
08
09 public class uploadImage extends Sprite {
10 private var jagFileRefSave:FileReference = new FileReference();
11 private var loader:Loader = new Loader();
12 private var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png");
13
14 public function uploadImage(){
15 super();
16 upload_Image.addEventListener(MouseEvent.CLICK,onClickSave);
17
18 }
19 private function onClickSave(e:MouseEvent):void{
20 jagFileRefSave.browse([imagesFilter]);
21 jagFileRefSave.addEventListener(Event.SELECT, selectedFile);
22 }
23 private function selectedFile(e:Event):void{
24 jagFileRefSave.load();
25 jagFileRefSave.addEventListener(Event.COMPLETE, loaded);
26 }
27 private function loaded(e:Event):void{
28 var rawBytes:ByteArray = jagFileRefSave.data;
29 loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData)
30 loader.loadBytes(rawBytes);
31 }
32 private function getBitmapData(e:Event):void{
33 addChild(loader);
34 }
35
36 }
37 }

Wednesday, July 22, 2009

how to check data in php

function showwelcome()
{
echo "
";
echo "";
echo "";
echo "";
echo "
";
}
function checkdata()
{
global $error_array;
if($_POST['name']=="")
{
$error_array[]="plz entr something";
}
}
function showerror()
{
global $error_array;
foreach($error_array as $key)
{
echo $key;
}}
function handledata()
{
echo $_POST['name'];
}
$error_array=array();
if(isset($_POST["welcomeseen"]))
{
checkdata();
if(count($error_array)!=0)
{
showerror();
showwelcome();
}
else
{
handledata();
}
}
else
{
showwelcome();
}

Monday, July 20, 2009

date difference

function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;

}
$date1="07/11/2003";
$date2="09/04/2004";

$dob="08/12/1975";
echo "If you were born on " . $dob . ", then today your age is approximately " . round(dateDiff("/", date("m/d/Y", time()), $dob)/365, 0) . " years.";
?>

how to enter phto in mysql using php

input type="hidden" name="MAX_FILE_SIZE" value="2000000
input name="userfile" type="file" id="userfile
input name="upload" type="submit" class="box" id="upload" value=" Upload











if(!$con)
{
die("conection failed".mysql_error());
}
$sql=mysql_select_db("photo",$con);if(!$sql){die("database failed".mysql_error());}
$uploadDir = 'C:/webroot/upload/';
if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result)
{
echo "Error uploading file";exit;}

if(!get_magic_quotes_gpc())
{$fileName = addslashes($fileName);
$filePath = addslashes($filePath);}
$query = "INSERT INTO upload2 (name, size, type, path ) "."VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";
mysql_query($query) or die('Error, query failed : ' . mysql_error());
mysql_close($con);
echo "
Files uploaded
";
}?>

Saturday, July 11, 2009

php6-control structure

Control Structures
divided into two groups: conditional control structures and loop control structures. The conditional control structures affect the flow of the program and execute or skip certain code according to certain criteria, whereas loop control structures execute certain code an arbitrary number of times according to specified criteria
A.Conditional Control Structures
Conditional control structures are crucial in allowing your program to take different execution paths based on decisions it makes at runtime. PHP supports both the if and switch conditional control structures.
1.if statement
The PHP if statement tests to see if a value is true, and if it is a segment of code will be executed.
$my_name = "someguy";
if ( $my_name == "someguy" )
{
statement1;//the coding appear here
}

?>

2.if..else
if if part is correct than statement1 execute else statement2 will execute.
$number_three = 3;
if ( $number_three == 3 ) {
statement1;
}
else
{
statement2;
}
?>

3.if...elseif
When PHP evaluates your If...elseif...else statement it will first see if the If statement is true. If that tests comes out false it will then check the first elseif statement. If that is false it will either check the next elseif statement, or if there are no more elseif statements, it will evaluate the else segment, if one exists
$employee = "Bob";
if($employee == "Ms. Tanner")
{
echo "Hello Ma'am";
}
elseif($employee == "Bob")
{
echo "Good Morning Sir!";
}
else
{
echo "Morning";
}
?>

4.switch
The way the Switch statement works is it takes a single variable as input and then checks it against all the different cases you set up for that switch statement. Instead of having to check that variable one at a time, as it goes through a bunch of If Statements, the Switch statement only has to check one time.
$destination = "New York";
echo "Traveling to $destination
";
switch ($destination){
case "Las Vegas":
echo "Bring an extra $500";
break;
case "Amsterdam":
echo "Bring an open mind";
break;
case "Egypt":
echo "Bring 15 bottles of SPF 50 Sunscreen";
break;
case "Tokyo":
echo "Bring lots of money";
break;
case "Caribbean Islands":
echo "Bring a swimsuit";
break;
default:
echo "Bring lots of underwear!";
break;
}
?>

php5-operator

arithmetic operator
+ Addition 2 + 4=6
- Subtraction 6 - 2=4
* Multiplication 5 * 3=15
/ Division 15 / 3 =5
% Modulus 43 % 10 =3(show the remainder)

1.Assignment Operators
operators:-
+=, -=, *=, /=, %=, ^=, .=, &=, |=, <<=, >>=
For example:
$counter += 2; // This is identical to $counter = $counter + 2;
$offset *= $counter;// This is identical to $offset = $offset * $counter;


2.Comparison Operators
Comparison operators enable you to determine the relationship between two operands
== Equal to
Checks for equality between two arguments performing type conversion when necessary:
1 == "1" results in true
1 == 1 results in true

!= Not equal to
Inverse of ==.
> Greater than
Checks if first operand is greater than second
< Smaller than
Checks if first operand is smaller than second
>= Greater than or equal to
Checks if first operand is greater or equal to second
<= Smaller than or equal to
Checks if first operand is smaller or equal to second

3.Logical Operators
Logical operators first convert their operands to boolean values and then perform the respective comparison.
Operator
&&, and
The result of the logical AND operation between the two operands

||, or
if the condition with of any operand is true than result is true
ex-$a=45;
if(a>30||a<50)
echo "arunrawat-web.blogspot.com";
//this print the arunrawat-web.blogspot.com
?>
Xor, Logical XOR
The result of the logical XOR operation between the two operands

increment/decrement operator
$var++, Post-increment
$var is incremented by 1.
The previous value of $var.

++$var, Pre-increment
$var is incremented by 1.
The new value of $var (incremented by 1).

$var--
Post-decrement
$var is decremented by 1.
The previous value of $var.

--$var, Pre-decrement
$var is decremented by 1.
The new value of $var (decremented by 1).

php4-managing varibles

Managing Variables
Three language constructs are used to manage variables. They enable you to check if certain variables exist, remove variables, and check variables' truth values.

1.isset()
isset() determines whether a certain variable has already been declared by PHP. It returns a boolean value true if the variable has already been set, and false otherwise, or if the variable is set to the value NULL. Consider the following script:

if (isset($first_name)) {
print '$first_name is set';
}
This code snippet checks whether the variable $first_name is defined. If $first_name is defined, isset() returns true, which will display '$first_name is set.' If it isn't, no output is generated.

isset() can also be used on array elements (discussed in a later section) and object properties. Here are examples for the relevant syntax, which you can refer to later:

Checking an array element:

if (isset($arr["offset"])) {
...
}



Checking an object property:

if (isset($obj->property)) {
...
}



Note that in both examples, we didn't check if $arr or $obj are set (before we checked the offset or property, respectively). The isset() construct returns false automatically if they are not set.

isset() is the only one of the three language constructs that accepts an arbitrary amount of parameters. Its accurate prototype is as follows:

isset($var1, $var2, $var3, ...);

It only returns TRue if all the variables have been defined; otherwise, it returns false. This is useful when you want to check if the required input variables for your script have really been sent by the client, saving you a series of single isset() checks.

2. unset()
unset() "undeclares" a previously set variable, and frees any memory that was used by it if no other variable references its value. A call to isset() on a variable that has been unset() returns false.

For example:

$name = "John Doe";
unset($name);
if (isset($name)) {
print '$name is set';
}




This example will not generate any output, because isset() returns false.

unset() can also be used on array elements and object properties similar to isset().

3.empty()
empty() may be used to check if a variable has not been declared or its value is false. This language construct is usually used to check if a form variable has not been sent or does not contain data. When checking a variable's truth value, its value is first converted to a Boolean according to the rules in the following section, and then it is checked for TRue/false.

For example:

if (empty($name)) {
print 'Error: Forgot to specify a value for $name';
}



This code prints an error message if $name doesn't contain a value that evaluates to true

php3-variables

variables in php
it is very easy to declare variables in php because there is no need to declare their type like in java or c.
$ sign is used in the front of the variable .
$a is the variable

There are a few rules that you need to follow when choosing a name for your PHP variables.

•PHP variables must start with a letter or underscore "_".
•PHP variables may only be comprised of alpha-numeric characters and underscores. a-z, A-Z, 0-9, or _ .
•Variables with more than one word should be separated with underscores. $my_variable
•Variables with more than one word can also be distinguished with capitalization. $myVariable

Indirect References to Variables
An extremely useful feature of PHP is that you can access variables by using indirect references, or to put it simply, you can create and access variables by name at runtime.

Consider the following example:

$name = "John";
$$name = "Registered user";
print $John;



This code results in the printing of "Registered user."

The bold line uses an additional $ to access the variable with name specified by the value of $name ("John") and changing its value to "Registered user". Therefore, a variable called $John is created.

You can use as many levels of indirections as you want by adding additional $ signs in front of a variable


Superglobals
As a general rule, PHP does not support global variables (variables that can automatically be accessed from any scope). However, certain special internal variables behave like global variables similar to other languages. These variables are called superglobals and are predefined by PHP for you to use. Some examples of these superglobals are

$_GET[]. An array that includes all the GET variables that PHP received from the client browser.
$_POST[]. An array that includes all the POST variables that PHP received from the client browser.
$_COOKIE[]. An array that includes all the cookies that PHP received from the client browser.
$_SERVER[]. An array with the values of the web-server variables.

php2-comments

how the comments work in php
comment r very necessay for the programmer to made for future use.A good programmer always declare the cooments
// is used for single line cooment



/*
this is used for multiple line comment

*/

Saturday, April 4, 2009

php1

TO DOWNLOAD APP SERVER WITH MYSQL AND PHP CLICK ON http://www.appservnetwork.com/
store all the php format file in www folder in c: directory appserv folder :
store the file with .php extension
to run the file open internet explorer and type http://localhost/filename.php in adress bar
PHP IS LOOSLEY TYPE LANGUAGE LIKE HTML.
Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in। The goal of the language is to allow web developers to write dynamically generated pages quickly।"
This is generally a good definition of PHP. However, it does contain a lot of terms you may not be used to. Another way to think of PHP is a powerful, behind the scenes scripting language that your visitors won't see!
When someone visits your PHP webpage, your web server processes the PHP code। It then sees which parts it needs to show to visitors(content and pictures) and hides the other stuff(file operations, math calculations, etc.) then translates your PHP into HTML. After the translation into HTML, it sends the webpage to your visitor's web browser.
Php is a loosely typed language therefore it is easy to work on it like HTML.