I would like to print the links of the images in the database. https://www.yelp.com/biz_photos/zesty-gyros-and-deli-grand-rapids
I connected using CURL. I took the links to the pictures using Preg_match_all and listed them as "FOR". But I get the error in the INSERT process to the database.
Parse the data
preg_match_all('@<div class="photo-box photo-box--interactive" data-photo-id=(.*?)>@si', $site, $mydata);
for ($a=0; $a<count($mydata[1]); $a++) {
echo $mydata[1][$a].'<br>';
}
25 results are listed below. But I couldn't do mysql insert.
mysqli_query($link,"INSERT INTO myTable (field) VALUES ($mydata[1][$a])") or die(mysqli_error($link));
use single quotations marks around your $mydata[1][$a] and put in mysqli_real_escape_string function.
$value = mysqli_real_escape_string($link, $mydata[1][$a]);
mysqli_query($link,"INSERT INTO myTable (field) VALUES ('".$value."')") or die(mysqli_error($link));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.