PHP MySql Insert

PHP Have Query Method for all types of SQL Operations.

MySQL Insert (Object Oriented)


<?php

$server="localhost";
$username="root";
$password="";
$db="e-commerce";

$conn=new mysqli($server,$username,$password,$db);

if($conn->connect_error){
	die("Error:".$conn->connect_error);
}

$InsertQuery="INSERT INTO Customers (FirstName,LastName,PhoneNumber,Address,Email)
 VALUES ('abc','xyz',0321000000,'abcd xyz','customer@gmail.com')";
 
$result=$conn->query($InsertQuery);
if($result===true){
	echo 'Successfully Record Inserted';
}else{
	echo 'Erro:'.$conn->error;
}

$conn->close();
?>

MySQL Insert (Procedural)


<?php

$server="localhost";
$username="root";
$password="";
$db="e-commerce";

$conn=mysqli_connect($server,$username,$password,$db);

if(!$conn){
	die("Error:".mysqli_connect_error());
}

$InsertQuery="INSERT INTO Customers (FirstName,LastName,PhoneNumber,Address,Email)
 VALUES ('abc','xyz',0321000000,'abcd xyz','customer@gmail.com')";
 
$result=mysqli_query($conn,$InsertQuery);
if($result===true){
	echo 'Successfully Record Inserted';
}else{
	echo 'Erro:'.mysql_error($conn);
}


mysqli_close($conn);
?>