only iterates last value in db
Posted: Thu Oct 13, 2005 3:02 pm
i have a database with 20 id numbers, i wanted to design a script so it grabs the id from the database uses it in a URL, then the script parses infromation from that URL and uploads the parsed info into another table and reiterate that for each id in the database. however the script iterates 20 times using the same id number (the last id number in the database). so after the script runs the table has 20 of the same pieces of information in it.
what am i doing wrong?
what am i doing wrong?
Code: Select all
<?
function <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>() {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://nw4.novaworld.net/NWStats.dll');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies');
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function getbannedcookie($file) {
$dbhost = "localhost";
$dbuname = "";
$dbpass = "";
$dbname = "";
$db = mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db($dbname, $db);
$q = "SELECT * FROM chid";
$result3 = mysql_query($q) or die ('Something is wrong with query: ' . $q . '<br>'. mysql_error());
while ($row = mysql_fetch_assoc($result3))
{
$chid = $row['chid'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://nw4.novaworld.net/NWStats.dll?success=bhd_6_stat.htm&failure=bhd_6_main.htm&relay=bhd_6_relay.htm&msgbase=bhd_6_msg.htm&nodb=bhd_6_nodb.htm&statpage=bhd_6_stat.htm&pfid=26&statslot=0&action=stats&showchid=' . $chid . '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
preg_match('/cid=(.*?), chid=(.*?), charactername="(.*?)" pcid="(.*?)"/', $file, $matches);
$chid1 = $matches[2];
$cid = $matches[1];
$name = $matches[3];
$pcid = $matches[4];
$result2 = mysql_query("INSERT INTO pcid SET chid='$chid1', cid='$cid', name='$name', pcid='$pcid'", $db) or die("Error: ".mysql_error());
}
}
getbannedcookie(<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>());
<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>();
?>