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

Breaking

Php mysql create database || how to Create php mysql database

MySQL Create Database

Since PHP 4.3, mysql_create_db() function is deprecated. Now it is recommended to use one of the 2 alternatives.
  • mysqli_query()
  • PDO::__query()

PHP MySQLi Create Database Example

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_connect_error());  
  9. }  
  10. echo 'Connected successfully<br/>';  
  11.   
  12. $sql = 'CREATE Database mydb';  
  13. if(mysqli_query( $conn,$sql)){  
  14.   echo "Database mydb created successfully.";  
  15. }else{  
  16. echo "Sorry, database creation failed ".mysqli_error($conn);  
  17. }  
  18. mysqli_close($conn);  
  19. ?>  
Output:
Connected successfully
Database mydb created successfully.