Tuesday 17 December 2019

php - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use nea

Answer


I get this error
//ERROR




ERRORINSERT INTO new_comp_reg (phno , fullname , address , dept , desc) VALUES ('','','','','')

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc) VALUES ('','','' ,'','')' at line 1




PHP




$servername = 'mysql.hostinger.in';
$username = '';
$password = '';

$dbname = 'u424351292_icrcm';

if(isset($_POST['submit']))
{
$phone_no = $_POST['phno'];
$full_name = $_POST['fullname'];
$location = $_POST['address'];
$department = $_POST['dept'];
$description = $_POST['desc'];
}


$conn = new mysqli($servername,$username,$password,$dbname);

if($conn->connect_error)
{
die("Connection Failed" . $conn->connect_error);
}

$sql = "INSERT INTO new_comp_reg (phno , fullname , address , dept , desc) VALUES ('$phone_no' , '$full_name' , '$location' , '$department' , '$description')";


if($conn->query($sql) === TRUE)
{
echo "Complaint Registered";
}
else
{
echo "ERROR".$sql."
".$conn->error;
}

$conn->close();

?>


//ERROR




ERRORINSERT INTO new_comp_reg (phno , fullname , address , dept , desc) VALUES ('','','','','')
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc) VALUES ('','','' ,'','')' at line 1


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...