Switch to full style
Dynamic open source server-side web development
Post a reply

How to Connect to MySql Server

Sat Apr 07, 2007 12:55 pm

How to connect to MYSQL database from PHP?
This is a code to connect to the database using PHP.one the local host.
    localhost= Server of Mysql database :!:
    username= root
    password=""
    Database name=book


Code:

         $connection 
=mysql_connect("localhost","root","",true,1);
      
mysql_select_db("library",$connection);

$result1 mysql_query ("SELECT * FROM               
                          book"
$connection);
                   
   while (
$row mysql_fetch_row($result1))
   {
     
// (4) Print out each element in $row, that is,
     // print the values of the attributes
      
for ($i=0$i";
   }
   // (5) Close the database connection
   mysql_close($connection);




Post a reply
  Related Posts  to : How to Connect to MySql Server
 connect to MYSQL from ASP     -  
 HELP CONNECT SQL SERVER 2005 WITH PHP 5.2.6     -  
 clients cannot connect to server on another machine     -  
 how to connect client on one machine with server     -  
 MySQL server information getting in php     -  
 MYSQL best performance optimized parameters for 4G server     -  
 How to connect two computers and connect them with Internet?     -  
 Sql server or windows server question?     -  
 Connect Dots     -  
 how to connect applet with excel     -  

Topic Tags

PHP Database