im connecting my php script with this simple code:
mysql_connect("localhost", "admin", "1admin") or die("DB Failed"); mysql_select_db("test") or die(mysql_error());
but when execute in terminal, DB failed. however this works on browser.
closed as off topic by George Stocker♦, Jay R, marc_s, Gilles, C. A. McCann Jul 12 '11 at 18:55Questions on Stack Overflow are expected to relate to programming within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question. |
|||||||||||||||||||||
|
PHP from commandline usually uses a different php.ini from php-cli. If your are on a linux server - look into /etc/php/cli/php.ini (Or something like that...) Check if mysql is enabled in this php.ini |
|||||
|
Try
Simply outputting "db failed" is useless for diagnost purposes, especially when MySQL will tell you exactly what's wrong with mysql_error(). |
|||||||||||||||||
|