Page 1 of 1

unable to connect to mysql

Posted: Sun Oct 22, 2006 5:27 am
by jasongr
Hi people

I have a php application which successfully connects to mysql and interacts with the database.
I am using apache as my web server.

I would like to invoke my code from the command shell, using php.exe like so:
c:\php\php.exe c:\script.php

in script.php I am using mysql_connect to connect to the database.
I get the following error:
Access denied for user 'root'@'localhost' (using password: YES)

Note that the same script is working perfectly when invoked via the web server...

what do I need to do in order to make my script work from the command line?

regards

Posted: Sun Oct 22, 2006 12:38 pm
by volka
The same script is running on the same pc using the same php.ini?

Posted: Mon Oct 23, 2006 5:50 am
by jasongr
I found the problem.
the fact that the code was involed from the command line, caused some of the global parameters in $_SERVER not to be initialized properly, and that caused me to attempt to connect to the database using the wrong password.