Error: INSERT INTO grocery ('GrocerID', 'GrocerName', 'Address', 'LogoImage') VALUES ('GID0072', 'BigBazaar','India, Andhra Pradesh, 522124','WIN_20150817_121614.JPG') You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''GrocerID', 'GrocerName', 'Address', 'LogoImage') VALUES ('GID0072', 'BigBazaar' at line 1
<?php
$servername = "localhost";
$username = "root";
$password = "secret";
$dbname = "task";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$GrocerID=$_POST['GrocerID'];
$GrocerName=$_POST['GrocerName'] ;
$Address=$_POST['Address'];
$LogoImage=$_POST['LogoImage'] ;
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO grocery ('GrocerID', 'GrocerName', 'Address', 'LogoImage')
VALUES ('$GrocerID', '$GrocerName','$Address','$LogoImage')";
if ($conn->query($sql) === TRUE) {
header('Location:task.html');
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Can someone please tell me what the mistake I'm doing here??
I have used database name: task, table name: grocery But i'm not able to understand where I'm doing the mistake.
Thankyou