blackcell Posted July 17, 2008 Share Posted July 17, 2008 Hello does anybody know where to find an article on how to run php scripts from the php.exe? I think I found some articles on google but not for sure if it is what I want. I am trying to execute a database update in the middle of the night without the web browser. Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/ Share on other sites More sharing options...
discomatt Posted July 17, 2008 Share Posted July 17, 2008 http://php.net/features.commandline Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592585 Share on other sites More sharing options...
blackcell Posted July 17, 2008 Author Share Posted July 17, 2008 Just looked at that article but I think this may be what I want can someone confirm? c:\path\to\php.exe -f c:\path\to\script.php Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592586 Share on other sites More sharing options...
blackcell Posted July 17, 2008 Author Share Posted July 17, 2008 I have it executing but it won't select the db when it reaches that line. Since I am at the command line is database functions different or do I need to go about the db interaction differently? Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592599 Share on other sites More sharing options...
discomatt Posted July 17, 2008 Share Posted July 17, 2008 No, it should still work fine... Try creating an error log by writing to a text file in the script directory, and make sure you know whats going wrong. Does the script execute fine from a browser? Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592609 Share on other sites More sharing options...
craygo Posted July 17, 2008 Share Posted July 17, 2008 If you include files then you may want to make sure they are being included correctly. May need to use absolute paths for the includes. Ray Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592610 Share on other sites More sharing options...
blackcell Posted July 17, 2008 Author Share Posted July 17, 2008 I ran it from the windows cl and it stops when I select the database. Says unknown database 'my_db_name'. THe script executes fine through the browser. Edit: Do I need to use the address instead of localhost? Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592631 Share on other sites More sharing options...
discomatt Posted July 17, 2008 Share Posted July 17, 2008 Localhost should still work fine. Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592649 Share on other sites More sharing options...
darkfreaks Posted July 17, 2008 Share Posted July 17, 2008 have you tried running a chron job ??? Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592654 Share on other sites More sharing options...
wildteen88 Posted July 17, 2008 Share Posted July 17, 2008 Make sure you have display_errors turned on and that error_reporting is set to E_ALL. Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592655 Share on other sites More sharing options...
blackcell Posted July 17, 2008 Author Share Posted July 17, 2008 C:\>\\server1\xampp\php\php-win.exe -e -f \\server1\xampp\htdocs\reports\openjob _rpt06.php Notice: Undefined index: REMOTE_ADDR in \\server1\xampp\htdocs\reports\openjob_ rpt06.php on line 126 Notice: Undefined index: REMOTE_HOST in \\server1\xampp\htdocs\reports\openjob_ rpt06.php on line 127 Could not select expedite on page \\server1\xampp\htdocs\reports\openjob_rpt0 6.php: Unknown database 'expedite' The bold is the only difference I have when turning error reporting to all. What is a cron job? Quote Link to comment https://forums.phpfreaks.com/topic/115267-running-script-from-phpexe/#findComment-592682 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.