schedule tasks Batch file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

schedule tasks Batch file

Post by JimiH »

Hello I have the following bat file that calls up a php script

Code: Select all

@echo OFF
 
"c:\Progra~1\php\php.exe" email_open_vsi.php %*
This is supposed to run a php script that fires off an email however I cant get it to work from the batch file,
running the php script from the browser is not a problem.

This is the error the batch files displays

Code: Select all

PHP Fatel error:  Call to undefined function mysql_query() etc etc
Anyone have any ideas?

Thanks

Geoff
caltoche
Forum Newbie
Posts: 6
Joined: Mon Jul 27, 2009 8:46 am

Re: schedule tasks Batch file

Post by caltoche »

Does mysql_connect and mysql_select_DB works ?
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

Re: schedule tasks Batch file

Post by JimiH »

No none of them work when called from the batch file. I did have an "include" to a connection php file but
have moved all this into my main php file.

Now its fails on the mysql_connect()

Its like when mysql is called from the command line it doesn't exist, but if called from the browser it does?

mysql is enabled and I can see it in the info.php

Thanks

Geoff
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: schedule tasks Batch file

Post by VladSun »

PHP CLI and PHP Apache module are different things.

You have a separate php.ini for PHP CLI and you must include MySQL library in it.

PS:
http://www.php.net/manual/en/features.commandline.php

Look at the -c option
There are 10 types of people in this world, those who understand binary and those who don't
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

Re: schedule tasks Batch file

Post by JimiH »

Thanks, I'm using PHP CLI

Shown by typing php -v

Code: Select all

C:\Documents and Settings\ajlsvradmin>php -v
PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Also there is only one php.ini on the IIS server and this has mysql enabled?

Geoff
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

Re: schedule tasks Batch file

Post by JimiH »

Ok, you where right I had two php.ini's

Now the code executes from the command line but throws an error about a missing dll "php4ts.dll"

Thanks

Geoff
JimiH
Forum Commoner
Posts: 92
Joined: Thu Jun 15, 2006 6:10 am

Re: schedule tasks Batch file

Post by JimiH »

Reinstalled PHP 5, now everything working correctly :D
Post Reply