Free download web templates, books and more. Free php projects ,games and apps. GTA mods and more

Breaking

Php Mysql Tutorial || how to store php datas in mysql

PHP MySQL Connect


php mysql function 3 types:
  • mysqli procedure
  • mysqli object oriented
  • pdo
Since PHP 5.5, mysql_connect() extension is deprecated. Now it is recommended to use one of the 2 alternatives.
  • mysqli_connect()
  • PDO::__construct()

PHP mysqli_connect()

PHP mysqli_connect() function is used to connect with MySQL database. It returns resource if connection is established or null.
Syntax
  1. resource mysqli_connect (server, username, password)  

PHP mysqli_close()

PHP mysqli_close() function is used to disconnect with MySQL database. It returns true if connection is closed or false.
Syntax
  1. bool mysqli_close(resource $resource_link)  

PHP MySQL Connect

Example
  1. <?php  
  2. $host = 'localhost:8080';  
  3. $user = '';  
  4. $pass = '';  
  5. $conn = mysqli_connect($host$user$pass);  
  6. if(! $conn )  
  7. {  
  8.   die('Could not connect: ' . mysqli_error());  
  9. }  
  10. echo 'Connected successfully';  
  11. mysqli_close($conn);  
  12. ?>  
Output:
Connected successfully