How to insert Data into MySQL Database Using PHP Code
ការបង្កើត MySQL Database Table និង Insert ដោយប្រើ PHP Code
See more videos by S O P H A L here : / @kithsophal
Start PHP Script:
$servername = "localhost"; $username = "username";
$password = "password"; $db = "dbname";
// Create connection
$conn = mysqli_connect($servername, $username, $password,$db);
// Check connection
if ($conn===false) {
die("Connection failed: " . mysqli_connect_error());
}
// Attempt create database query execution
$sql = "CREATE DATABASE demo";
if(mysqli_query($conn, $sql)){
echo "Database created successfully";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($conn);
End PHP Script:
// Attempt create Table query execution
$sql = "CREATE TABLE persons( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(30) NOT NULL, email VARCHAR(70) NOT NULL UNIQUE )";
// Attempt Insert Into Table query execution
$sql = "INSERT INTO persons (first_name, last_name, email) VALUES ('Peter', 'Parker', 'peterparker@mail.com’)”;
// Attempt Insert Into Table Multiple Record query execution
$sql = "INSERT INTO persons (first_name, last_name, email) VALUES ('John', 'Rambo', 'johnrambo@mail.com'), ('Clark', 'Kent', 'clarkkent@mail.com'), ('John', 'Carter', 'johncarter@mail.com'), ('Harry', 'Potter', 'harrypotter@mail.com')";
Facebook: https://fb.com/sophal.official/
Support My Channel
Do LIKE | COMMENT | SHARE | SUBSCRIBE
On this page of the site you can watch the video online How to insert Data into MySQL Database Using PHP Code with a duration of hours minute second in good quality, which was uploaded by the user KITH Sophal 19 April 2020, share the link with friends and acquaintances, this video has already been watched 81 times on youtube and it was liked by 2 viewers. Enjoy your viewing!