i'll post the whole code when i get back on the computer
and i figured what happened with sql i ' ' the colum name lol so thats fixed
i'll either edit this post like above or repost when i get on
<?php
include('config.php');
include('opendb.php');
/* gets the data from a URL */
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$itemid= 6;
for($i=2; $i<=$itemid; $i++) {
$returned_content = get_data('http://URL?=' . $itemid . '');
$html = str_replace(array("\r","\n"), "", $returned_content);
$regexp = '#Insert Content Here#';
preg_match($regexp, $html, $matches);
if (count($matches)==0){
echo "";
}else{
$name = $matches[1];
$img = $matches[2];
$alt = $matches[3];
$dis = $matches[4];
$price = $matches[5];
$change1 = $matches[6];
$change2 = $matches[7];
$change3 = $matches[8];
echo "" . $price . "<br>";
echo "" . $change1 . "<br>";
echo "" . $change2 . "<br>";
echo "" . $change3 . "<br>";
echo "" . $name . "<br>";
echo "" . $alt . "<br>";
echo "" . $dis . "<br>";
echo "" . $img . "<br>";
unset($matches);
mysql_query("INSERT INTO Item (name, img, alt, dis, price, change1, change2, change3, itemid) VALUES ('$name', '$img', '$alt', '$dis', '$price', '$change1', '$change2', '$change3', '$img');") or die(mysql_error());
echo " Added! </ br>";
}
}
?>
the $img is the same as id as its a ?=#
Edit sql before or after unset it dont matter... im trying it on xampp before i try on a server.