Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- // Create connection
- $conn = new mysqli($servername, $username, $password);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // Create database
- $sql = "CREATE DATABASE IF NOT EXISTS `loja` CHARSET = UTF8 COLLATE = utf8_general_ci;";
- if ($conn->query($sql) === TRUE) {
- echo 'Database criada.';
- } else {
- echo "Error creating database: " . $conn->error;
- }
- $db_selected = mysqli_select_db($conn, "loja");
- if (!$db_selected)
- {
- die ('Can\'t use database : ' . mysqli_error());
- }
- else
- {
- $sql2 = "CREATE TABLE customers( ".
- "id INT NOT NULL AUTO_INCREMENT, ".
- "name VARCHAR(40) NOT NULL, ".
- "password VARCHAR(50) NOT NULL, ".
- "email VARCHAR(50) NOT NULL, ".
- "PRIMARY KEY ( id )); ";
- $conn->query($sql2);
- echo '<br> Tabelas criadas';
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement