Fatal error: Uncaught mysqli_sql_exception: 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 ''crud' ('first name', 'last name', 'phonenumber', 'email', 'password', 'birth...' at line 1 in C:\xampp\htdocs\crud\regForm.php:15 Stack trace: #0 C:\xampp\htdocs\crud\regForm.php(15): mysqli_query(Object(mysqli), 'INSERT INTO 'cr...') #1 {main} thrown in C:\xampp\htdocs\crud\regForm.php on line 15
My code:
<?php
include 'connect.php';
if(isset($_POST['submit'])){
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$pnum=$_POST['pnum'];
$email=$_POST['email'];
$pass=$_POST['pass'];
$bday=$_POST['bday'];
$gender=$_POST['gender'];
$sql = "INSERT INTO 'crud' ('first name', 'last name', 'phonenumber', 'email', 'password', 'birthday', 'gender')
VALUES('$fname', '$lname', '$pnum', '$email', '$pass', '$bday', '$gender')";
$result = mysqli_query($con,$sql);
if($result){
echo "DATA INSERTED SUCCESSFULLY";
}else{
die(mysqli_error($con));
}
}
?>
What I have tried:
i tried exclude the connect.php but still cant work and i ran out of ideas