Forum Moderators: coopster
Can anyone please look through this and give me some pointers on what I can possibly do to fix this? I am going crazy right now!
Oh and 1st time poster, long time lurker :P
<?PHP
require_once('mysql_connect.php');$filelist = explode("\n",`find XML -name '*.xml'`);
foreach ($filelist as $location) {
//$location = 'XML/YAMAHA_2008_22226_03172008/YAMAHA_2008_108724.xml';
if (strlen(trim($location)) !== 0 ){
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname,$conn);
echo '<h3>I AM LOCATION: ' . $location . '</h3><br>';
$file = file_get_contents($location);
$xml2 = new SimpleXMLElement($file);
foreach($xml2->model_info->Children() as $node){
$string = $node->getName();
$query = sprintf("INSERT INTO elements (model,file) VALUES ('%s','%s')",
mysql_real_escape_string($string),
mysql_real_escape_string($location));
mysql_query($query,$conn) or die(mysql_errno);
}
$mfg = $xml2->model_info->make;
$model = $xml2->model_info->productname ;
$query1 = sprintf("INSERT INTO models (mfg,model,file) VALUES ('%s','%s','%s')",mysql_real_escape_string($mfg),mysql_real_escape_string($model),mysql_real_escape_string($location));
echo '<b>Query 1: </b>' . $query1 . '<br>';
mysql_query($query1,$conn) or die(mysql_errno);
echo '<b>Memory In Use: </b>' . memory_get_usage() . '<br>' . "\n";
echo '<b>Peak Usage: </b>' . memory_get_peak_usage(). '<BR>' . "\n";
echo 'I= ' . $i . '<br>';
$i++;
}
echo 'A= ' .$a . '<BR>';
$a++;
$xml2 = &$GLOBALS[$name];
unset ($GLOBALS[$name]);
unset($location);
unset($conn);
unset($file);
unset($node);
unset($query);
unset($query1);
unset($mfg);
unset($model);
}
?>
And from my knowledge there is no way to force garbage collection.