Click here to Skip to main content
15,844,498 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

include 'connect.php';

  $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);

What I have tried:

i tried exclude the connect.php but still cant work and i ran out of ideas
Updated 4-Aug-23 4:34am
CHill60 4-Jul-22 5:49am    
What are the values in each of those parameters?
Richard MacCutchan 4-Jul-22 6:48am    
Try removing the single quotes from 'crud'; (just a guess).
0x01AA has the answer.
0x01AA 4-Jul-22 10:06am    
Does not MariaDB use ` instead of ' to quote fieldnames?
Richard MacCutchan 4-Jul-22 12:36pm    
That should be a solution.
0x01AA 4-Jul-22 12:54pm    
Thanks for the push ;)

1 solution

Please see here: Identifier Names - MariaDB Knowledge Base[^]
Identifiers may be quoted using the backtick character - `.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900