I got a cron job with the following code:
<?php
require "config.php";
$truncate = $mysqli->query("TRUNCATE rss_feed");
$cars = $mysqli->query("SELECT *,(SELECT title FROM companies WHERE companies.company_id = cars.company_id) AS car_company,(SELECT car_model FROM models WHERE models.model_id = cars.model_id) AS car_model FROM cars, companies WHERE cars.company_id = companies.company_id AND car_active = 'Active' AND rssPost IS NULL ORDER BY datetime DESC");
$result = $cars->num_rows;
if ($result > 0) {
while ($row_cars = $cars->fetch_array()) {
$title = $row_cars['car_company'] . ' ' . $row_cars['car_model'] . ' ' . $row_cars['car_cc'];
$link = '/car.php?id=' . $row_cars['car_id'];
$description = $row_cars['car_description'];
$datetime = $row_cars['datetime'];
$row_car_id = $row_cars['car_id'];
$insert = $mysqli->query("INSERT INTO rss_feed (title, link, description, datetime) VALUES ('$title','$link','$description','$datetime')");
$update = $mysqli->query("UPDATE cars SET rssPost='Yes' WHERE car_id = '$row_car_id'");
if (!$insert) {
printf("ERROR: %s\n", $mysqli->error);
}
}
printf($result . " cars inserted");
} else {
printf("No new cars inserted");
}
I've set cPanel to run the php file every 3 hours and i got he error below:
/public_html/system/cron_rss.php: line 1: ?php: No such file or directory
/public_html/system/cron_rss.php: line 2: require: command not found
/public_html/system/cron_rss.php: line 3: syntax error near unexpected token `('
/public_html/system/cron_rss.php: line 3: `$truncate = $mysqli->query("TRUNCATE rss_feed");'
If i run the file through the URL, it works ok without errors. My IDE editor confirms that there is no suspicious code. I got 755 CHMOD for the file.