kevinkorb Posted August 24, 2007 Share Posted August 24, 2007 I have PHP 5.2.3 running on Windows Server 2K3. Everything works fine through apache, however I'm creating some automated tasks and wanted to us Windows Task Scheduler to run them through the command line. Test 1: - Send simple email: <code> <?php mail("[email protected]", "test email sub1", "test body", "From: [email protected]"); ?> </code> Now I tried running that three different ways. (I have a copy of the php.ini in the same folder as the script I'm running) I tried: php test.php php -n test.php php-win test.php The only one that completed and sent the email was php -n test.php. Then I ran a simple test to try to connect to my database. After trying to run it every way I thought I could, the error message came back that it couldn't instantiate the mysqli class. So I imagine it is a php.ini problem, however I'm not able to resolve it in any way. Any ideas? thanks Link to comment https://forums.phpfreaks.com/topic/66524-solved-php-windows-cli/ Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 What if you try, instead of running the php file, to run iexplore with the php file in the command line: "iexplore php c:\test.php" I don't know if it is any different, but you might try it. Link to comment https://forums.phpfreaks.com/topic/66524-solved-php-windows-cli/#findComment-333127 Share on other sites More sharing options...
kevinkorb Posted August 24, 2007 Author Share Posted August 24, 2007 That does work, however I'm looking for a 'best practices' solution. The box is going to be working very hard to begin with (The mysql database is at about 25 million rows in 130 tables) the budget is decent for the project, I would really not want to resort to ie for automated tasks. You solution would work, however I'm looking for a bit more. Thank you. Link to comment https://forums.phpfreaks.com/topic/66524-solved-php-windows-cli/#findComment-333164 Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 How does it run the other way you do it? I think they best way to automate it would be to make a simple application in vb. Then you could schedule that. Or you could use cronjobs to automate it. Link to comment https://forums.phpfreaks.com/topic/66524-solved-php-windows-cli/#findComment-333187 Share on other sites More sharing options...
kevinkorb Posted August 24, 2007 Author Share Posted August 24, 2007 I can create a simple .bat file containing... php d:\www\vhosts\mydomain.com\myfiletoautomate.php and then Schedule that through the task scheduler. That part is easy, its just getting php to play nicely in the command line format that is the problem. Link to comment https://forums.phpfreaks.com/topic/66524-solved-php-windows-cli/#findComment-333194 Share on other sites More sharing options...
kevinkorb Posted August 24, 2007 Author Share Posted August 24, 2007 I figured it out. I copied my php.ini file to the same folder and then gutted the extensions except for mysqli (which I will defiantly need). Then to call the php script I used: php -c php.ini test.php It worked. I'm chalking it up to an extension(s) that isn't compatible with the php cli for windows. Way too much fun for what I wanted to do. Link to comment https://forums.phpfreaks.com/topic/66524-solved-php-windows-cli/#findComment-333200 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.