Page 1 of 1

schedule tasks Batch file

Posted: Tue Jul 28, 2009 7:13 am
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

Re: schedule tasks Batch file

Posted: Tue Jul 28, 2009 10:02 am
by caltoche
Does mysql_connect and mysql_select_DB works ?

Re: schedule tasks Batch file

Posted: Wed Jul 29, 2009 4:26 am
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

Re: schedule tasks Batch file

Posted: Wed Jul 29, 2009 4:29 am
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

Re: schedule tasks Batch file

Posted: Wed Jul 29, 2009 5:48 am
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

Re: schedule tasks Batch file

Posted: Wed Jul 29, 2009 6:28 am
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

Re: schedule tasks Batch file

Posted: Thu Jul 30, 2009 4:08 am
by JimiH
Reinstalled PHP 5, now everything working correctly :D