Amaan 11
Amaan 11
mysqli_close($conn);
?>
Delete:
<?php
$conn = mysqli_connect("localhost", "root", "", "FYCS24");
if (mysqli_query($conn, $sql)) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . mysqli_error($conn);
}
mysqli_close($conn);
?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
try {
$conn = new PDO("mysql:host=$servername", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "CREATE DATABASE KCFYCS63";
// use exec() because no results are returned
$conn->exec($sql);
echo "Database created successfully<br>";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
Creating table:
<?php
try {
$conn = new PDO("mysql:host=localhost;dbname=KCFYCS64", "root", "");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->exec($sql);
echo "Table Users created successfully";
} catch(PDOException $e) {
echo "Error creating table: " . $e->getMessage();
}
$conn = null;
?>
Inserting record:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "KCFYCS64";
try {