Hi All.
I have been trying to add a cron job for the past couple of days to update one of my banners. As the tittle says I am trying to use PHP to deploy. Simply swapping the img file with cron won't do for this as it causes issues with temporary files etc.
I have separated the connection and the job as I always have. My process is as follows:
db-connect.php
cron_job.phpPHP Code:<?php
// set db access info as constants
define ('DB_USER','####');
define ('DB_PASSWORD','####');
define ('DB_HOST','localhost');
define ('DB_NAME','####');
// make connection and select db
$dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
mysql_select_db(DB_NAME) OR die ('Could not select the db: ' . mysql_error() );
?>
The SQL query works when run via php MyAdmin.PHP Code:<?php
require_once('/home/####/public_html/cron/db-connect.php'); // connect to db
$query = "REPLACE INTO `####`.`zen_banners` (
`banners_id` ,
`banners_title` ,
`banners_url` ,
`banners_image` ,
`banners_group` ,
`banners_html_text` ,
`expires_impressions` ,
`expires_date` ,
`date_scheduled` ,
`date_added` ,
`date_status_change` ,
`status` ,
`banners_open_new_windows` ,
`banners_on_ssl` ,
`banners_sort_order`
)
VALUES (
'15', 'Welcome', '', '', 'homepageslide', '<img src="images/banners/open_soon.png" alt="Open Daily 17:00hrs to 23:00hrs" class="banner-img"><div class="banner" /><p>Open at 17:00hrs<span></p></div>', NULL , NULL , NULL , '0001-01-01 00:00:00', '0001-01-01 16:45:00', '1', '1', '1', '0');
");
$result = @mysql_query($query); // run the query
?>
I am using the following line as my cron command line:
I just need to update the banner image a couple of time during our day (open and closing times for our store). No matter what I try I can't get this to function.Code:/usr/bin/php /home/####/public_html/cron/cron_job.php >/home/####/public_html/cron/new.txt
Can anyone see the mistake? Any general advice?
My PHP is v5.4. Let me know if you need to know anything else. Any help gratefully received.
Thanks all


Reply With Quote
