Code has been added to clipboard!

Creating MySQL Tables for MySQLi Users

Example
<?php
  $host = 'host';
  $user = 'user';
  $pass = 'pass';
  $db =  'db';
  // Create connection  
  $conn = mysqli_connect($host, $user, $pass, $db);  	
  // Check connection  	
  if (!$conn) {      
    die("Failed to connect: " . mysqli_connect_error());
  }
  // sql to create table  	
  $sql = "CREATE TABLE users (user_id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(40) NOT NULL,password VARCHAR(40) NOT NULL,email VARCHAR(60),register_date TIMESTAMP)";  	
  if (mysqli_query($conn, $sql)) {    
    echo "users table created successfully";
  } else {
    echo "Failed to create table: " . mysqli_error($conn);
  }
  mysqli_close($conn);  
?>