Created
June 4, 2023 17:16
-
-
Save AbhishekGhosh/73e908db4aa656be205e1bdbd04f21fd to your computer and use it in GitHub Desktop.
Create MySQL Table With PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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