Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Created June 4, 2023 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhishekGhosh/73e908db4aa656be205e1bdbd04f21fd to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/73e908db4aa656be205e1bdbd04f21fd to your computer and use it in GitHub Desktop.
Create MySQL Table With PHP
<?php
$servername = "localhost";
$username = "non-root";
$password = "non-root-password";
$dbname = "ESP32IoT";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "CREATE TABLE LED_status (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
status INT(11) NOT NULL
)";
if ($conn->query($sql) === TRUE) {
echo "Table has been created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment