• Register
0 votes
60 views

Problem :

I am very new to the php and I am trying from long time but I cannot sort out the issue with my below code. Please let me know how can I fix the error?

"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 ' '0')' at line 1"

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

You must have misplaces your single quote at the end of your query.

In below line of code:

$sql="INSERT INTO `product_tbl` (`product_name`, `product_details`, `product_cat`, `product_sub_cat`, `product_img`, `meta_title`, `meta_description`, `schema`, `product_status`) VALUES ('$pname', '$content', '$category', '$subcat', '$pathname', '$meta_title', '$meta_description', '$schema,' '0');";

At the very end you have the  '$schema,' '0');";

If you try to look at it more carefully then you can see that you have closed a single quote for a $schema after your comma. and It should be the '$schema', '0');";

This will surely solve your current problem, but as per my experience I can tell you that your code looks very vulnerable to the SQL Injection. So it is always better to do some research on it and how to fix the issue(Using the prepared statements and the parameter binding).

 

9 7 4
38,600 points

Related questions

0 votes
1 answer 43 views
43 views
Problem : I have a Stored procedure like below: CREATE PROCEDURE MyProG() BEGIN SELECT * FROM `hs_hr_employee_leave_quota`; END But it gives me the below error: #1064 - 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 '' at line 3 What does this error mean? What is wrong with my line number 2?
asked Jan 30, 2020 jwilliam 3.9k points
0 votes
2 answers 861 views
861 views
Problem : I have created the tables in MySQL Workbench. But when I try to insert the values into the ORDRELINJE table i get below error: Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (srdjank.Ordrelinje, CONSTRAINT Ordrelinje_fk FOREIGN KEY ... (OrdreID)) I have seen many other posts on this topic but unable to fix my issue. How can I fix this issue?
asked Jan 24, 2020 jwilliam 3.9k points
0 votes
2 answers 248 views
248 views
Problem : I have created the tables in MySQL Workbench. But when want to insert values into my TBL ORDRELINJE table I face below error : Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (srdjank.TBLOrdrelinje, CONSTRAINT TBLOrdrelinje_fk FOREIGN KEY ... do the research on this topic, but no luck. Am I doing any mistake or someone have any idea about what can I do?
asked Dec 21, 2019 alecxe 7.5k points
0 votes
1 answer 42 views
42 views
Problem: Hi, i upgraded the wordpress to Wordpress 5..2.2 but it popups a notification that my server is running an older version. Can anyone suggest me the best solution.
asked Nov 2, 2020 prog_learner 2.5k points
0 votes
1 answer 9 views
0 votes
1 answer 29 views
29 views
Problem: I have installed wordpress and wordpress them setting on cpanel,but now i am facing this issue that wordpress detected my website is at risk can anyone help to resolve this issue.
asked Nov 1, 2020 prog_learner 2.5k points
0 votes
2 answers 186 views
186 views
Problem : Looking for the solution of the following Security error. fatal error: please read "security" section of the manual to find out how to run mysqld as root!
asked Nov 12, 2019 peterlaw 6.9k points
0 votes
1 answer 51 views
51 views
Problem: I am new, I need help, can anyone help me by filling in the blanks? A ____ is a question, or, in database terms, a request for specific information from the database?
asked Feb 19, 2020 maddi86 5.4k points
0 votes
1 answer 11 views