<?php
$starttime = microtime();
################################ ################################
################################ GALAXY ################################
################################ ################################
################################ ################################
$filu=file("galaxy_listing");
$galaxy = array_slice($filu, 9,count($filu));
preg_match("([0-9]{1,})",$filu[4],$tick); //tick number in the $tick[0]
$aika = $filu[3];
$aika=strstr($aika,"2"); //$aika = the time yyyy-mm-dd hh-minutes-seconds ISO
$var= count($galaxy) - 2;
$i=0 ;
while($i <= $var ){
$rivi= explode("\t",$galaxy[$i]);
//$rivi[0] cluster
//$rivi[1] paraller
//$rivi[2] gal name
//$rivi[3] gal score
#then add to db
$sqldb="scripts";
include("C:\\sqlconf.inc");
$sqlcheck = "SELECT `tick` FROM `planedb` WHERE `tick` = $tick[0]";
$result = mysql_query($sqlcheck,$connect2);
if (mysql_num_rows($result) > 0) {
echo mysql_query($sqlcheck,$connect2) ? "true" : "false"; /* for debug */
echo "Info is already in db!";break; //stops while
}else{
$sql="INSERT INTO planedb VALUES('$tick[0]','$rivi[0]','$rivi[1]','$rivi[2]','$rivi[3]')";
mysql_query($sql,$connect2) ;
$i++;
}
} //while function ends
mysql_close($connect2); //close the con
?>
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<head>
<title>Title here!</title>
</head>
<body>
<p>Press update when u're ready
<form name="form" method="post" action="<?php echo $PHP_SELF;?>">
<input type="submit" name="Submit" value="Update">
</form>
<?php //page was generated in....
$endtime = microtime();
$parts_of_starttime = explode(' ', $starttime);
$starttime = $parts_of_starttime[0] + $parts_of_starttime[1];
$parts_of_endtime = explode(' ', $endtime);
$endtime = $parts_of_endtime[0] + $parts_of_endtime[1];
$time_taken = $endtime - $starttime;
$time_taken = number_format($time_taken, 2); // optional
print "<center><font size=\"-1\"><br>Sivu luotiin ".$time_taken." sekunnissa</font>"; ?>
</body>
ok the problem is this:
the script always says that the $tick is in the db, even when the db is empty!!