I run a windows 2003 server and tried to run a code like this every 15 minutes:
require("db_connect.php");
$conn = db_connect();
//list online brukere - flytt funksjon til separat side for bedre ytelse
$time = time() - 900;
$query ="SELECT username FROM tbl_user WHERE last_online >= $time";
$online_users;
if ($result = $conn->query($query)) {
while ($row = $result->fetch_assoc()) {
$online_users .= $row["username"].":";
}
$result->close();
}
$filename = "online_users.txt";
$fp = fopen($filename,"w");
fputs($fp,$online_users);
fclose($fp);
When I go to the url or run it from the command line it works and write to file. But the task just run and don't save the file.. What's wrong?
You might not have permission to write to relative path.
So, chose another path with enough write permission, and please, use absolute path instead.