create table in mysql

In this tutorial,Create Table In Mysql we’ll use php_ini library and php.ini file. MySQL or MariaDB server will be used to run the server. You can learn more about MySQL and MariaDB in our previous post.

Do you want to Some people say that use mysql_real_escape_string() instead of mysql_query() is faster, but still is not as fast as PHP_MYSQL_QUERY_STRING. Since PHP 5.5, mysql_query() function is deprecated. Now it is recommended to use one of the 2 alternatives. Some people say that use instead of is faster, but still is not as fast as PHP_MYSQL_QUERY_STRING. MySQL NULL SQL Connection Errors

  1. mysqli_query()
  2. PDO::__query()

PHP MySQL Create Table Tutorial:

Example

<?php  
$host = 'localhost:3306';  
$user = '';  
$pass = '';  
$dbname = 'laratuto';  
  
$conn = mysqli_connect($host, $user, $pass,$dbname);  
if(!$conn){  
  die('Could not connect: '.mysqli_connect_error());  
}  
echo 'Database Connected successfully<br/>';  
  
$sql = "create table users(id INT AUTO_INCREMENT,EmailId VARCHAR(20) NOT NULL,  
users_token INT NOT NULL,primary key (id))";  
if(mysqli_query($conn, $sql)){  
 echo "Table users created successfully";  
}else{  
echo "Could not create table: ". mysqli_error($conn);  
}  
  
mysqli_close($conn);  
?>  

Output:

Connected successfully
Table emp5 created successfully

Leave a Comment