in my php
code, I've a sql string select * from tablename where url in (%s)
;
I'm constructing the input array from urls
, which is array of url strings. $urls = array("https://www.example.com", "https://www.example.com/try002");
I've tried multiple ways but no luck.
Method 1:
$inputParams = array(implode(", ", $urls));
this gives me error of 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 '://www.example.com,https://www.example.com/photos/try002)'
Method 2: So I tried to add both double and single escape quotes, because when I try in sql db, select * from tablename where url in ("https://www.example.com", "https://www.example.com/blabla")
works.
foreach($urls as &$url)
{
$url = "'" . urlencode($url) . "', ";
}
$inputParams = array($urls);
Neither of double or single quotes worked. It produces query of select * from tablename where url in (
\"https://example.com\", "www.example.com/blabla")
How should I formulate my input urls so that I can get something like select * from tablename where url in ("https://www.example.com", "https://www.example.com/blabla")
please?
Much appreciated.