-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
48 lines (40 loc) · 1.08 KB
/
index.php
File metadata and controls
48 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
$link = new mysqli('localhost', 'root', '', '');
$link->set_charset('utf8');
if ($link)
{
echo "conexao ok";
}
else
{
die('Connect Error (' . mysqli_connecterrno() . ')' .
mysqli_connect_error());
}
$nomeBanco = "meubanco";
$query_create_schema = "CREATE SCHEMA IF NOT EXISTS $nomeBanco"
or die ("Error in the consult .. " . $link->connection_error);
$result_create_schema = $link->query($query_create_schema);
if ( $link->query($query_create_schema) === TRUE )
{
echo "<p>criou banco de dados </p>";
}
else
{
echo "<p>nao criou banco de dados</p>";
}
mysqli_select_db($link , $nomeBanco);
$query_create_table = "CREATE TABLE IF NOT EXISTS clients (
id int AUTO_INCREMENT PRIMARY KEY,
nome varchar(60) NOT NULL,
email varchar(60) NOT NULL)"
or die("Error in the create table ... " . $link->connect_error);
$result_create_table = $link->query($query_create_table);
if($result_create_table == TRUE)
{
echo "<p>criou a tabela</p>";
}
else
{
echo "<p>nao criou a tabela</p>";
}
?>