Answer the question
In order to leave comments, you need to log in
How to correctly insert variables into this query?
$query='SELECT*FROM answer WHERE title="'.$row['title'].'" ORDER BY id DESC LIMIT "'.$art.'", "'.$kol.'"';
Gives the error 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 '"0", "3"' at line 1
Answer the question
In order to leave comments, you need to log in
sprintf? And Limit must have numeric values, and you place a string there, i.e. remove the double quotes.
The best option would be to use placeholders.
But in your case you can do this:
$query = "SELECT * FROM answer WHERE title='{$row['title']}' ORDER BY id DESC LIMIT {$art}, {$kol}";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question