Re: Mysql does not work well in PHP configuration
|
Clifford Haff |
|
5/11/2008 11:59:47 PM |
This works: $link = mysqli_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
This doesn't: $link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
Thanks for any advice.
Post Comments |
|
Re: Mysql does not work well in PHP configuration
|
Oniel Hanley |
|
5/12/2008 12:00:04 AM |
And what is the error message you get from the one that fails? either the PHP or preferably the MySQL error message.....
the or dies construct can be usefull, especailly in the live code to handle an error gracefully, but it doens't give much help on Post Comments |
|
The error message is:
Access denied for user 'SYSTEM'@'localhost' (using password: NO)
When I search on this message, it usually comes back saying you are using a root account without a password and I am not using root, I do have a password on the account and I can login with either the Mysql CLI or mysqli_connect with the same values.
Thanks
Post Comments |
|
Re: Mysql does not work well in PHP configuration
|
Amrutha Vinay |
|
5/12/2008 12:04:08 AM |
Have you verified (echoed) what "$dbServer", "$dbUser", and "$dbPass&q uot; contain? The error message is indicating that at least the user and password were empty. Post Comments |
|
Just did that, the variables echo with the correct host, user and password
Thanks
Post Comments |
|
Re: We cannot really tell you what you might...
|
Amrutha Vinay |
|
5/12/2008 12:10:23 AM |
Since you have not really posted any of your code (the one line does not count as it does not show the context it is being used in), we cannot really tell you what you might or might not have overlooked.
Unless you have -
$dbServer = "localhost"; $dbUser = "SYSTEM"; $dbPass = "";
The posted line of code did not generate the posted error message. To get specific help with what your code is doing, you need to post your actual code (xxxxx out any sensitive information but don't change any of the syntax or punctuation.)
Also, add the following two lines after your first opening <?php tag -
PHP Code: ini_set ("display_errors", "1");
error_reporting(E_ALL);
Edit: I am going to take a wild educated guess and say the proble m is that your mysql_connect() statement is not being executed at all (probably because it is c ontained in a block of code using a short open php tag <? or in an include file that is not being included) and the error message you posted actually refers to the line number of a mysql_ query() statement (or perhaps a mysql_select_db() statement) that is attempting to open a conne ction to the mysql server using all default values. Post Comments |
|
Thank you!
Got the following message after inserting the two lines above: Notice: mysql_connect() [function.mysql-connect]: SQL safe mode in effect - ignoring host/user/password information in C:\Program Files\Apache\Apache2.2\htdocs\test1.php on line 15
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\Program Files\Apache\Apache2.2\htdocs\test1.php on line 15 Could not connect
So I disabled SQL.safe_mode in php.ini, restarted Apache and now mysql_connect is working.
I am in a test environment at this time, so turning it off is no big deal for now.
Will read up on safe mode to see what my options are.
Thank you again!
Post Comments |
|
Re: I am sure its just something minor
|
Clifford Haff |
|
5/12/2008 12:07:11 AM |
I am sure its just something minor I have overlooked.
Post Comments |
|