Hello guys,

I'm a kinda new the site, I can't seem to get the stock analyzer program 100% 
operational

my problem seems to be the analysis.php file. I get the following errors when compiled. any help will be greatly appreciated.


PHP Warning: Division by zero in /home5/teamwith/public_html/Stocks/analysis/analysis_a.php on line 78
PHP Warning: Missing argument 1 for insertIntoResultTable()

here is my code

<?php
include("../includes/connect.php");
function masterLoop()
{
$mainTickerFile = fopen("../tickerMaster.txt", "r");

while(!feof($mainTickerFile)){

$companyTicker=fgets($mainTickerFile);
$companyTicker=trim($companyTicker);

$nextDayIncrease=0;
$nextDayDecrease=0;
$nextDayNoChange=0;
$total=0;

$sumOfIncreases=0;
$sumOfDecreases=0;

$sumOfNoChange=0;
$averageIncreasePercent=0;
$averageDecreasePercent=0;

$sql="SELECT date, percent_change FROM $companyTicker WHERE percent_change < '0' ORDER BY date ASC";
$result= mysql_query($sql);

if($result)
{
while($row=mysql_fetch_array($result))
{
$date=$row['date'];
$percent_change= $row['percent_change'];
$sql2 = "SELECT date, percent_change FROM $companyTicker WHERE date > $date ORDER BY date ASC LIMIT 1";
$result2= mysql_query($sql2);
$numberOfRows= mysql_num_rows($result2);

if($numberOfRows==1)
{
$row2=mysql_fetch_row($result2);
$tom_date=$row2[0];
$tom_percent_change= $row2[1];

if($tom_percent_change > 0)
{
$nextDayIncrease= $nextDayIncrease++;
$sumOfIncreases+= $tom_percent_change;
$total++;

else if($tom_percent_change < 0)
{
$nextDayDecrease++;
$sumOfDecreases+= $tom_percent_change;
$total++;
}
else
{
$nextDayNoChange++;
$total++;
}

}
else if($numberOfRows==0)
{
//no data after today
}
else
{
echo "you have an error in analysis_a";
}
}
}else
{
echo" unable to select $companyTicker  <br />";
}

  $nextDayIncreasePercent=($nextDayIncrease/$total)*100;
  $nextDayDecreasePercent=($nextDayDecrease/$total)*100;
  $averageIncreasePercent=$sumOfIncreases/$nextDayIncrease;
  $averageDecreasePercent=$sumOfDecreases/$nextDayDecrease;
  
insertIntoResultTable();
}
}
function insertIntoResultTable($companyTicker,$nextDayIncrease,$nextDayIncreasePercent,$averageIncreasePercent,$nextDayDecrease,$nextDayDecreasePercent,$averageDecreasePercent)
{
$kentrelsBuyValue=$nextDayIncreasePercent*averageIncreasePercent;
$kentrelsSellValue=$nextDayDecreasePercent*averageDecreasePercent;

$query="SELECT * FROM analysisA WHERE ticker='$companyTicker'";
$result=mysql_query($query);
$numberOfRows=mysql_num_rows($result);

if($numberOfRows==1)
{
$sql= "UPDATE analysisA SET ticker='$companyTicker',daysInc='$nextDayIncrease',pctOfDaysInc='$nextDayIncreasePercent',avgIncPct='$averageIncreasePercentage',daysDec='$nextDayDecrease',pctofDaysDec='$nextDayDecreasePercent',avgDecPct='averageDecreasePercentage',kentrelsBuyValue='$kentrelsBuyValue',kentrelsSellValue='$kentrelsSellValue' WHERE ticker='$companyTicker'";
} else{
$sql="INSERT INTO analysisA (ticker,daysInc,pctOfDaysInc,avgIncPct,daysDec,pctofDaysDec,avgDecPct,kentrelsBuyValue,kentrelsSellValue) VALUES ('$companyTicker','$nextDayIncrease','$nextDayIncreasePercent,'$averageIncreasePercent','$nextDayDecrease','$nextDayDecreasePercent','$averageDecreasePercentage','$kentrelsBuyValue','$kentrelsSellValue')";
}

}