• Register
0 votes
37 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

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 28 views
28 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 jwilliam 3.9k points
0 votes
2 answers 551 views
551 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 jwilliam 3.9k points
0 votes
2 answers 193 views
193 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