Click here to Skip to main content
15,886,006 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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 ''fyp2' ('name','gender','age','health','absences','test1','test2') value...' at line 1 in C:\xampp\htdocs\fyp2\user.php:14 Stack trace: #0 C:\xampp\htdocs\fyp2\user.php(14): mysqli_query(Object(mysqli), 'insert into 'fy...') #1 {main} thrown in C:\xampp\htdocs\fyp2\user.php on line 14

where is my error? I can't seem to find it.

this is my code:


What I have tried:

i have try anything but there's no solution.
Posted
Updated 19-Jul-23 23:10pm
Comments
moses kehinde 26-Apr-23 13:34pm    
how to fix php error 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 'id']; ?>'' at line 1 in C:\xampp version\htdocs\demo\update.php:28 Stack trace: #0 C:\xampp version\htdocs\demo\update.php(28): mysqli->query('SELECT * FROM `...') #1 {main} thrown in C:\xampp version\htdocs\demo\update.php on line 28

At a guess - and it can only be a guess, since you haven't shown any of your code - you have used the wrong delimiters for the table and column names.

Your error message refers to both insert into 'fy... and 'fyp2' ('name','gender','age','health','absences','test1','test2'), so it looks like you're putting single quotes (ASCII code 39, ') around the table and column names.

MySQL and MariaDB require that you use the backtick (ASCII code 96, `) to quote names:
MySQL :: MySQL 8.0 Reference Manual :: 9.2 Schema Object Names[^]

Fix your query to resolve the error.
SQL
insert into `fyp2` (`name`, `gender`, `age`, `health`, `absences`, `test1`, `test2`) ...
 
Share this answer
 
Comments
Pacifique Nezerwa 28-Oct-22 8:15am    
Thank you very much! This works and helps a lot
We have no idea - We can't see the line of code at all as we have no access to your system.

So ... look at line 14 of user.php and find the bit of the SQL Command string it uses (which may be on a line a bit above line 14), then find the bit that mentions fyp2 and look at the SQL before and after it. It should be pretty obvious - you wrote it after all, so you know what you meant to type - but if it isn't, then start with W3Schools SQL[^] and find the command type and closely examine what you are trying to execute.

Sorry, but we can't do any of that for you!
 
Share this answer
 
Ok. I think you ought to notice the difference between ` and '. the two characters are not same. you should use ` to enclose your table fields. eg. INSERT INTO `fy` (`email`, `password`,.......). that should eliminate the error.
 
Share this answer
 
Comments
Patrice T 20-Jul-23 5:13am    
I think you ought to notice the question is more than 1 year old. lets hope solution was found in between.
CHill60 20-Jul-23 6:37am    
Exactly what was said in Solution 2 over a year ago.
If you are going to add solutions to old threads please ensure you are adding something new to the conversation and not just repeating the same information

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