unable to connect to mysql

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
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

unable to connect to mysql

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

The same script is running on the same pc using the same php.ini?
jasongr
Forum Contributor
Posts: 206
Joined: Tue Jul 27, 2004 6:19 am

Post 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.
Post Reply