• Register
0 votes
136 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 83 views
83 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
1 answer 30 views
30 views
Problem : mysql server version for the right syntax to use near '' at line 1
asked Feb 13 Shovo210 13.9k points
0 votes
1 answer 2 views
2 views
Problem: How to use mysql server version for the right syntax to use near?
asked 2 days ago padma1 22.4k points
0 votes
1 answer 2 views
2 views
Problem: If you could lead me in the right way, I would appreciate it.
asked 2 days ago zayed1 35.6k points
0 votes
1 answer 1 view
1 view
Problem: I need someone’s help to fix it... innodb_buffer_pool_size mariadb
asked Mar 24 Ifra 24.4k points
0 votes
1 answer 7 views
7 views
Problem: How can I fix this issue:Error 1452: cannot add or update a child row: a foreign key constraint fails .
asked Mar 15 Wafa Abu Yousef 6.1k points
0 votes
2 answers 1.4K views
1.4K 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 335 views
335 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 2 views
2 views
Problem: Please assist me in resolving this issue: you have an error in your sql syntax near ' '' at line 1
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 30 views
30 views
Problem: cara mengatasi you have an error in your sql syntax near ' '' at line 1
asked Feb 12 Dan phillip 4.8k points