OpenForumPG
OpenForumPG
Topic |
Posts |
Last Post |
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//create a database named forumdb
$sql = "CREATE DATABASE forumdb";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
//select the database
$conn->select_db("forumdb");
//create a table named posts with three columns
$sql = "CREATE TABLE posts (
topic_name VARCHAR(255) NOT NULL,
post_content TEXT NOT NULL,
user_name VARCHAR(255) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo "Table created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
//close the connection
$conn->close();
?>
//close the database connection
$conn->close();
?>