PHP/MySQL Database/Database Connection

Материал из Web эксперт
Перейти к: навигация, поиск

Close database connections

   <source lang="html4strict">

<?php

  @mysql_connect("mysql153.secureserver.net","wbex","password") or die("Could not connect to MySQL server!");
  @mysql_select_db("wbex") or die("Could not select database!");
  echo "You"re connected to a MySQL database!";
  mysql_close();

?>


      </source>
   
  


PHP code to establish a connection with MySQL

   <source lang="html4strict">
 <?php
 $host="mysql153.secureserver.net";
 $uname="wbex";
 $pass="password";
 
 $connection= mysql_connect ($host, $uname, $pass);
 if (! $connection) {
   die ("A connection to the Server could not be established!");
 } else {
   echo "User root logged into to MySQL server ",$host," successfully.";
 }
 ?>


      </source>