oracle765 Posted January 7, 2014 Share Posted January 7, 2014 Hi Professionals I have been testing a php cron job and it is producing errors in the email response it sends to me, I have looked and looked and cannot see what seems to be wrong. Any ideas thanks in advance masters.php error.txt Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/ Share on other sites More sharing options...
oracle765 Posted January 7, 2014 Author Share Posted January 7, 2014 oh and the cronjob is * * * * * /home/username/public_html/scripts/master.php Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464236 Share on other sites More sharing options...
PaperTiger Posted January 7, 2014 Share Posted January 7, 2014 Have you tried running the script in the browser and seeing if it works then? Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464240 Share on other sites More sharing options...
boompa Posted January 7, 2014 Share Posted January 7, 2014 (edited) /home/oracle765/public_html/scripts/masters.php: line 1: ?: No such file or directory Use <?php rather than just <? Actually, add this at the top of the script: #!/usr/bin/env php /home/oracle765/public_html/scripts/masters.php: line 3: syntax error near unexpected token `(' Line should be mysql_select_db('mydatabase') or die('Could not select database.<br>' . mysql_error()); although I'm not sure why you're using an HTML tag there. Edited January 7, 2014 by boompa Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464241 Share on other sites More sharing options...
oracle765 Posted January 7, 2014 Author Share Posted January 7, 2014 ok firstly how I didn't notice the beginning of the file not saying <?php I don't know silly me anyway I have attached the new file and taken out the html stuff but I am still getting the same error masters.php Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464253 Share on other sites More sharing options...
oracle765 Posted January 7, 2014 Author Share Posted January 7, 2014 oh and I have tried running the webpage in the browser and when I go into the database it has not inserted the .csv file I have also put the full path in but that didn't work Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464255 Share on other sites More sharing options...
jazzman1 Posted January 7, 2014 Share Posted January 7, 2014 (edited) To be able to run a file into a cron schedule make sure that the file has executable rights. For the issue with .csv file, do you try to import the data from mysql command client line? EDIT: What sql errors did you get running the script through the browser? Edited January 7, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464297 Share on other sites More sharing options...
taquitosensei Posted January 7, 2014 Share Posted January 7, 2014 make sure any includes aren't full path not relative and try using /usr/bin/php -f /home/username/public_html/scripts/master.php oh and the cronjob is * * * * * /home/username/public_html/scripts/master.php Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464305 Share on other sites More sharing options...
oracle765 Posted January 7, 2014 Author Share Posted January 7, 2014 I tried putting /usr/bin/php -f /home/username/public_html/scripts/masters.php in the cron job but then the emails stopped coming through I also tried typing http://www.compareandchoose.com.au/scripts/masters.php in the browser and ti also did not load the data into the database but just shows a blank screen as there is no html output I am so lost as to what it could be because those ` parenthesis around $dbH don't even exist in my code Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464357 Share on other sites More sharing options...
GetFreaky Posted January 8, 2014 Share Posted January 8, 2014 (edited) I tried putting /usr/bin/php -f /home/username/public_html/scripts/masters.php in the cron job but then the emails stopped coming through I also tried typing http://www.compareandchoose.com.au/scripts/masters.php in the browser and ti also did not load the data into the database but just shows a blank screen as there is no html output I am so lost as to what it could be because those ` parenthesis around $dbH don't even exist in my code op are you sure your database credentials are correct Edited January 8, 2014 by GetFreaky Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464379 Share on other sites More sharing options...
oracle765 Posted January 8, 2014 Author Share Posted January 8, 2014 yeah they are correct Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464386 Share on other sites More sharing options...
jazzman1 Posted January 8, 2014 Share Posted January 8, 2014 What linux distro are you running? Is it a remote or local machine? Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464388 Share on other sites More sharing options...
oracle765 Posted January 8, 2014 Author Share Posted January 8, 2014 its localmachine on the godaddy webhost Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464389 Share on other sites More sharing options...
GetFreaky Posted January 8, 2014 Share Posted January 8, 2014 (edited) Btw, could you try to print 1; On the top of your script, to see if file even runs the code. You said its a blank screen/no error output, its what I'm seeing also. Edited January 8, 2014 by GetFreaky Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464390 Share on other sites More sharing options...
jazzman1 Posted January 8, 2014 Share Posted January 8, 2014 (edited) Shared or dedicated server are you using to GoDaddy? PS: By LocalHost and LocalMachine I mean your home desktop, personal machine Edited January 8, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464392 Share on other sites More sharing options...
GetFreaky Posted January 8, 2014 Share Posted January 8, 2014 This could be a configuration problem, check your Apache's error log OP. Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464394 Share on other sites More sharing options...
oracle765 Posted January 8, 2014 Author Share Posted January 8, 2014 it shows a 1 at the top of screen Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464395 Share on other sites More sharing options...
jazzman1 Posted January 8, 2014 Share Posted January 8, 2014 What's the common b/w Apache and Cron? Cron could be run without php, mysql and apache at all. Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464396 Share on other sites More sharing options...
jazzman1 Posted January 8, 2014 Share Posted January 8, 2014 @oracle765 I'm out You don't know the basic things. Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464397 Share on other sites More sharing options...
Solution GetFreaky Posted January 8, 2014 Solution Share Posted January 8, 2014 (edited) What's the common b/w Apache and Cron? Cron could be run without php, mysql and apache at all. from OP oh and I have tried running the webpage in the browser and when I go into the database it has not inserted the .csv file I have also put the full path in but that didn't work I understood that the his query is faulty and doesn't generate the table values... however mysql_error() should ouput if something is wrong, and its still blank page with no error. Unless a new entry is inserted with blank values, then what I said above is irrelevant. Edited January 8, 2014 by GetFreaky Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464398 Share on other sites More sharing options...
oracle765 Posted January 8, 2014 Author Share Posted January 8, 2014 Well I have no idea, I am totally lost but its defo not updating the DB Quote Link to comment https://forums.phpfreaks.com/topic/285162-cron-job-seems-to-be-something-wrong-with-my-php/#findComment-1464402 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.