mysqli
mysql
table creation
5 years, 5 months ago
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "newDB";
// checking connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql code to create table
$sql = "CREATE TABLE employees(
id INT(2) PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50)
)";
if ($conn->query($sql) === TRUE) {
echo "Table employees created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
0 Comments
Please Login to Comment Here