Archive for 2011

database create in php with mysql

connection.inc.php :

<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
 {echo '<br>host coonected<br>';}
else
  {
  die('Could not connect ');
  }
?>
=========================================================
 database_creation.php :

<?php

require 'connection.inc.php';
if(isset($_POST['db'])&&!empty($_POST['db']))
{
$db1=$_POST['db'];
if (mysql_query("create database $db1",$con))
  {
  echo "<br>Database created<br>";
  }
else
  {
  echo '<br>database not created<br> :'.mysql_error().'<br>';
  }
}
else
{ echo '<br>please write database name below<br><br>' ; }
mysql_close($con);
?>

<form action="database_creation.php" method="POST">
<input type="text" name="db">
<input type="submit" name="submit">
</form>

===============================================================
run " database_creation.php "

output :


host coonected

please write database name below

host coonected

please write database name below

   "here button is there"

How to install Microsoft's SQL Server Driver for PHP

There are many questions on Microsoft's SQL Server driver for PHP forum from people that cannot work out how to install the PHP driver.

There is a page on the PHP site with help on choosing the right extension build:
http://php.net/manual/en/install.pecl.windows.php, and general help is here: http://php.net/manual/en/install.windows.extensions.php.

Here are some explicit instructions which I hope can help new users of PHP.  After a while all of this will become common sense.

Instruction notes:

  1. Microsoft's PHP driver for SQL Server only runs with PHP 32-bit builds (as standard from http://windows.php.net/download).
  2. These instructions are only for PHP 5.2, 5.3 or 5.4. 
  3. I am pretending that PHP is installed into folder C:\PHP.  Replace the term C:\PHP in the instructions with whatever folder your PHP is installed into.
Instructions:
  1. Download Microsoft's PHP drivers.  Open page: http://www.microsoft.com/en-us/download/details.aspx?id=20098
    1. If you have Windows Vista, Server 2008 or above, download SQLSRV30.EXE.
    2. If you have Server 2003/Windows XP or below, download SQLSRV20.EXE
    3. If you cannot find SQLSRV20.EXE and would like to try a custom build of driver version 3.0 for Windows XP/2003...
      1. See this post: Unofficial php_sqlsrv 3.0 and download the rar archive
      2. Change step (2.) below - the driver files are in the 'bin' sub-folder in the archive. just extract the contents of the 'bin' folder to your extensions folder.
      3. When you extract the files, rename them as follows in order to work with the rest of these instructions:
        php_sqlsrv_30_54_ts_vc9x86.dll => php_sqlsrv_54_ts.dll
        php_sqlsrv_30_54_nts_vc9x86.dll => php_sqlsrv_54_nts.dll
        php_pdo_sqlsrv_30_54_ts_vc9x86.dll => php_pdo_sqlsrv_54_ts.dll
        php_pdo_sqlsrv_30_54_nts_vc9x86.dll => php_pdo_sqlsrv_54_nts.dll
        php_sqlsrv_30_53_ts_vc9x86.dll => php_sqlsrv_53_ts.dll
        php_sqlsrv_30_53_nts_vc9x86.dll => php_sqlsrv_53_nts.dll
        php_pdo_sqlsrv_30_53_ts_vc9x86.dll => php_pdo_sqlsrv_53_ts.dll
        php_pdo_sqlsrv_30_53_nts_vc9x86.dll => php_pdo_sqlsrv_53_nts.dll
      4. Change step (3.) below - if you cannot install (3.1) SNAC version 2012, install from (3.2) version 2008r2 - either will work.
      5. Assume for step (6.) below that you downloaded SQLSRV30.EXE.
         
  2. Extract the entire contents of the file downloaded in (1.) to your PHP extensions folder.  This is usually a sub-folder of the location where php is installed, named 'ext', e.g. C:\PHP\ext.
    Note that you can use WinRAR to open the .exe file and extract the files, if you want.
     
  3. Download the SQL Server Native Client (SNAC), the PHP driver depends on it:
    1.  For SQLSRV30.EXE, go here: http://www.microsoft.com/en-us/download/details.aspx?id=29065#SNAC
    2. For SQLSRV20.EXE, go here: http://www.microsoft.com/en-us/download/details.aspx?id=16978#SNAC
    Note:
    1. If PHP will run on 64-bit Windows, download the X64 Package.
    2. If PHP will run on 32-bit Windows, download the X86 Package.
       
  4. Install the SQL Server Native Client downloaded from the previous step (3.) on the same computer that runs PHP.
     
  5. Find out which version of PHP you have:
    1. Open a command window (run cmd.exe)
    2. Using your PHP folder, run command: "C:\PHP\php.exe" -i | more
      'more' loads the information page by page.
    3. The top line will show PHP Version => 5.x.x...  Make a note of the version.  It will start with 5.4, 5.3 or 5.2.  The final (3rd) number is not important.

      For the next steps you may need to scroll to the 2nd information page in the console window, by pressing a key...
    4. For version 5.4 and 5.3, a little further down is setting PHP Extension Build => API... It will end with either ...TS,VCn or ...NTS,VCn.  Make a note of whether it says TS or NTS.  Also make a note of whether the final part is VC9 or VC6 (VC6 is still possible with PHP 5.3).
    5. For version 5.2, note the setting that says "Thread Safety enabled" or "Thread Safety disabled". 
      "Thread Safety enabled" means TS,VC6
      "Thread Safety disabled" means NTS,VC6.
       
  6. Edit your php configuration file, php.ini.  Go to the end of the file and add these lines, depending on your earlier choices.  You need to know your PHP version number (5.2, 5.3 or 5.4), and your TS/NTS setting, and whether you have a VC9 or VC6 build, all noted from step 5. above.

    You can calculate the files you need by looking at the file name and comparing to your PHP version, and remembering whether you downloaded SQLSRV20.exe or SQLSRV30.exe.  Here are all of the combinations that are possible:

    • For SQLSRV30.EXE, PHP 5.4, NTS, VC9 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_54_nts.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_54_nts.dll
       
    • For SQLSRV30.EXE, PHP 5.4, TS, VC9 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_54_ts.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_54_ts.dll
       
    • For SQLSRV30.EXE, PHP 5.3, NTS, VC9 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_53_nts.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_53_nts.dll
       
    • For SQLSRV30.EXE, PHP 5.3, TS, VC9 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_53_nts.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_53_nts.dll
       
    • For SQLSRV20.EXE, PHP 5.3, NTS, VC9 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_53_nts_vc9.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_53_nts_vc9.dll
       
    • For SQLSRV20.EXE, PHP 5.3, NTS, VC6 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_53_nts_vc6.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_53_nts_vc6.dll
       
    • For SQLSRV20.EXE, PHP 5.3, TS, VC9 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_53_ts_vc9.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_53_ts_vc9.dll
       
    • For SQLSRV20.EXE, PHP 5.3, TS, VC6 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_53_ts_vc6.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_53_ts_vc6.dll
       
    • For SQLSRV20.EXE, PHP 5.2, NTS, VC6 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_52_nts_vc6.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_52_nts_vc6.dll
       
    • For SQLSRV20.EXE, PHP 5.2, TS, VC6 add lines:
      [PHP_SQLSRV]
      extension=php_sqlsrv_52_ts_vc6.dll
      [PHP_PDO_SQLSRV]
      extension=php_pdo_sqlsrv_52_ts_vc6.dll
       
  7. Restart your web server for the change to take effect.

comparison operators in php

                                           comparison operators :   == , <= , >= , != , < , > 



<?php
$num1=10;
$num2='10';


if($num1==$num2)
echo "$num1 is equal to $num2";


?>
output : 


nothing to display , $num1 is integer and  $num2 is string , string is not equal to integer


<?php
$num1=10;
$num2=20;


if($num1==$num2)
echo "$num1 is equal to $num2";


?>
output : 


nothing to display , because both are not equal





<?php

$num1=10;
$num2=20;


if($num1<=$num2)
echo "$num1 is less than or equal to $num2";


?>
output : 10 is less than or equal to 20



<?php
$num1=10;
$num2=20;


if($num1>=$num2)
echo "$num1 is grater than or equal to $num2";


?>

output : 


nothing to display , because 10  is not grater than or equal to 20






<?php

$num1=10;
$num2=20;


if($num1!=$num2)
echo "$num1 is not equal to $num2";


?>
output : 10 is not equal to 20



<?php
$num1=10;
$num2=20;


if($num1<$num2)
echo "$num1 is less than to $num2";


?>
output : 10 is less than to 20





<?php

$num1=10;
$num2=20;


if($num1>$num2)
echo "$num1 is grater than $num2";


?>
output :
nothing to display , because10  is not grater than to 20
















PHP Strings



 This session demonstrates how PHP can provide dynamic content according to browser type, randomly generated numbers or User Input. It also demonstrated how the client borwser can be redirected.
Identifying Browser & Platform
PHP creates some useful environment variables that can be seen in the phpinfo.php page that was used to setup the PHP environment.
One of the environemnt variables set by PHP is HTTP_USER_AGENT which identifies the user's browser and operating system.
PHP provides a function getenv() to access the value of all the environment variables. The information contained in the HTTP_USER_AGENT environment variable can be used to create dynamic content appropriate to the browser.
Following example demonstrates how you can identify a client borwser and operating system.
NOTE: The function preg_match()is discussed in PHP Regular expression session.
<html>
<body>
<?php
   $viewer = getenv( "HTTP_USER_AGENT" );
   $browser = "An unidentified browser";
   if( preg_match( "/MSIE/i", "$viewer" ) )
   {
      $browser = "Internet Explorer";
   }
   else if(  preg_match( "/Netscape/i", "$viewer" ) )
   {
      $browser = "Netscape";
   }
   else if(  preg_match( "/Mozilla/i", "$viewer" ) )
   {
      $browser = "Mozilla";
   }
   $platform = "An unidentified OS!";
   if( preg_match( "/Windows/i", "$viewer" ) )
   {
      $platform = "Windows!";
   }
   else if ( preg_match( "/Linux/i", "$viewer" ) )
   {
      $platform = "Linux!";
   }
   echo("You are using $browser on $platform");
?>
</body>
</html>
This is producing following result on my machine. This result may be different for your computer depnding on what you are using.
You are using Mozilla! on Windows!
Display Images Randomly
The PHP rand() function is used to generate a random number.i This function can generate numbers with-in a given range. The random number generator should be seeded to prevent a regular pattern of numbers being generated. This is achieved using the srand() function that specifiies the seed number as its argument.
Following example demonstrates how you can display different image each time out of four images:
<html>
<body>
<?php
  srand( microtime() * 1000000 );
  $num = rand( 1, 4 );
  
  switch( $num )
  {
  case 1: $image_file = "/home/images/alfa.jpg";
          break;
  case 2: $image_file = "/home/images/ferrari.jpg";
          break;
  case 3: $image_file = "/home/images/jaguar.jpg";
          break;
  case 4: $image_file = "/home/images/porsche.jpg";
          break;
  }
  echo "Random Image : <img src=$image_file />";
?>
</body>
</html>
Using HTML Forms
The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.
Try out following example by putting the source code in test.php script.
<?php
  if( $_POST["name"] || $_POST["age"] )
  {
     echo "Welcome ". $_POST['name']. "<br />";
     echo "You are ". $_POST['age']. " years old.";
     exit();
  }
?>
<html>
<body>
  <form action="<?php $_PHP_SELF ?>" method="POST">
  Name: <input type="text" name="name" />
  Age: <input type="text" name="age" />
  <input type="submit" />
  </form>
</body>
</html>
  • The PHP default variable $_PHP_SELF is used for the PHP script name and when you click "submit" button then same PHP script will be called and will produce following result:
  • The method = "POST" is used to post user data to the server script. There are two methods of posting data to the server script which are discussed in PHP GET & POST chapter.
Browser Redirection
The PHP header() function supplies raw HTTP headers to the browser and can be used to redirect it to another location. The redirection script should be at the very top of the page to prevent any other part of the page from loading.
The target is specified by the Location: header as the argument to the header()function. After calling this function the exit() function can be used to halt parsing of rest of the code.
Following example demonstrates how you can redirect a borwser request to another web page. Try out this example by puttingthe source code in test.php script.
<?php
  if( $_POST["location"] )
  {
     $location = $_POST["location"];
     header( "Location:$location" );
     exit();
  }
?>
<html>
<body>
   <p>Choose a site to visit :</p>
   <form action="<?php $_PHP_SELF ?>" method="POST">
   <select name="location">
      <option value="http://w3c.org">
            World Wise Web Consortium
      </option>
      <option value="http://www.google.com">
            Google Search Page
      </option>
   </select>
   <input type="submit" />
   </form>
</body>
</html>
Displaying "File Download" Dialog Box
Sometime it is desired that you want to give option where a use will click a link and it will pop up a "File Download" box to the user in stead of displaying actual content. This is very easy and will be achived through HTTP header.
The HTTP header will be different from the actual header where we send Content-Typeas text/html\n\n. In this case content type will be application/octet-streamand actual file name will be concatenated alongwith it.
For example,if you want make a FileName file downloadable from a given link then its syntax will be as follows.
#!/usr/bin/perl

# HTTP Header
print "Content-Type:application/octet-stream; name=\"FileName\"\r\n";
print "Content-Disposition: attachment; filename=\"FileName\"\r\n\n";

# Actual File Content
open( FILE, "<FileName" );
while(read(FILE, $buffer, 100) )
{
   print("$buffer");
}

how to find password of email address msn hacked

I found these people reliable, efficient and not too expensive to hack into facebook . I found a bunch of places where people offer their services to yahoo password hack free. It costs a lot! Has anyone ever used http://www.hackfacebookprofile.com hacking services? They are really professional in hacking email password. I would recommend them. Thank you.

BTW, I found another website which is providing for free a free facebook hacking software and other one specialized in hack into someone's facebook password, hack facebook account id number.

Jordan N. Wilson,
Lawton, OK
United States

Related articles:
how to find password of email address msn hacked

delete table in php with mysql

connection.inc.php :

<?php
$host='localhost';
$user_name='root';
$password='';
@$con = mysql_connect("$host","$user_name","$password");
if ($con)
 {echo '<br>host coonected<br>';}
else
  {
  die('Could not connect ');
  }
?>

del_table.php :

<?php

require 'connection.inc.php';

if (mysql_select_db('test'))
if(mysql_query("delete from test where sno = 1",$con))
  {  $result=mysql_query("select * from test where sno = 1",$con);
     echo "<br><table><tr><td>sno</td><td>name</td></tr>";
     while($data = mysql_fetch_array($result))
  {
  echo "<tr><td>".$data['sno'] . "</td><td>" .$data['name']."</td></tr>";
  }
  echo "</table><br>data deleted<br>";
  }
else
  {
  echo '<br>data not selected :'.mysql_error().'<br>';
  }

mysql_close($con);
?>



run " del_table.php "

output :


host coonected

snoname

data deleted

Step by step blog creation tutorials using PHP & MySQL: Part-1


Primary discuss of a PHP blog

Everyone wants to create personal blog using PHP, though you can use WordPress for personal blog. It is not possible to be a PHP professional without completing any PHP projects. To be an advanced web developers you need to complete more projects such as PHP shopping cart, PHP online exam etc. Here I give you step by step tutorials on personal blog. 

This tutorial developed only for advanced users. If you think that you are not an advanced PHP developers just skip this tutorial and try to learn our PHP basic tutorials.



Before tending to continue our discussion at first we need to analyze the  primary requirement of a blog. Requirement analysis is very important for future decision. I divide the requirement analysis into two parts. 
  • Functional analysis and 
  • Database analysis or Entity analysis

Functional Analysis for Personal blog

Functional analysis means what function do a blog. Such functions are login, registration, blog post, category, comments, user maintenance etc. Here are some lists of functional analysis that is essential for a blog. 

Posts: Where you can create post, edit your post etc. 

Comments: Comments is very essential for a blog. Fro this section you can make comments and admin also be able to moderate comments. 

Category: In that section you can select category for specific post. 

Registration: From this section a user easily be able to create account for this blog. 

Admin Panel: This is back-end part and a normal user cannot enter this part. Only admin can enter this part and can be able to edit, delete posts or users and also can moderate comments. 

User login and logout is another important part for a PHP blog. I also include those parts though you are already familiar about this.

I will cover all the section throughout my whole PHP blog creation tutorials. In next tutorial I will discuss Database or Entity analysis. I hope you will enjoy every tutorials. If you face any problem from my tutorial....... please make sure your comments. I try my best to solve your problem. Thanks.

PHP Header 301 Redirect - Moved Permanently

From time to time, pages change location. At times like these, one can use PHP header function with 301 to notify website visitors that the page has moved, assuming the $location contains the new URL.

Here is how you can use PHP header 301 redirect


header ('HTTP/1.1 301 Moved Permanently');
header ('Location: '.$location);


More information about header function can be obtained at PHP.net

Php $_POST Variable

PGP $_POST variable is a predefined php variable name, and values are sent by the HTTP POST method, exactly like $_GET variable, but data sent from a form with $_POST method is invisible to user.


Example :

"myform.html":

<form action="collect.php" method="POST">
Name: <input type="text" name="name" />
Email: <input type="text" name="email" />
<input type="submit" />
</form>

"collect.php"

<? php
echo $_POST["name"] ."<br />";
echo $_POST["email"] ;
?>

With POST method you can send any amount of data from the HTML form. It is useful when you want to collect... large text, passwords etc.

Membase

Membase is high performance key value pair system used for cacheing data. Membase generally provide superset of memcached.

You can use Membase to and configure either "memcached" type or "membase" type buckets. A membase-type bucket provides additional features such as key-value persistence and replication, whereas a memcached-type bucket provides only memory-only caching.

Memcached has it’s limitations. Moving to large+1 machines is going to lose a lot of your data. There is no master to organize the re-balancing of the data.We can avoid data loss using membase bucket type, while adding new server to the clusters.

Moxi

Moxi is the component of Membase that handles the re-routing of requests to other Membase servers when the server receiving the original request is not the one responsible for the data requested.

You can install membase using the instructions here.

testing membase.

you can test it using telnet utility.

shell> telnet localhost 11211 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'

set test_key 0 0 1 a STORED
or you can run a PHP script to check if membase is installed properly or not.

connect("localhost",11211); // try 127.0.0.1 instead of localhost
// if it is not working

echo "Server's version: " . $memcache->getVersion() . "
\n";

// we will create an array which will be stored in membase serialized
$testArray = array('horse', 'dog', 'pig');
$tmp = serialize($testArray);
$memcache->add("key", $tmp);
echo "Data from the cache:
\n";
print_r(unserialize($memcache->get("key")));
?>