Show sourcecode
The following files exists in this folder. Click to view.
webbserver/ovningar/databas/2/
createtable2.php
dbconnection2.php
createtable2.php
35 lines ASCII Windows (CRLF)
<!-- createtable.php -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Create</title>
</head>
<body>
<?php
include ('dbconnection2.php');
try {
// sql to create table
$sql = "CREATE TABLE users (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user VARCHAR(15) UNIQUE,
password VARCHAR(50),
)";
// use exec() because no results are returned
$dbconn->exec($sql);
echo "Table created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
//Rensa kopplingen till databasen
$dbconn = null;
?>
</body>
</html>