I have been banging my head on this for several days nad have not been able to find a solution anywhere.
I am running Apache 2.2, PHP 5.0.27, Mysql 5.0.45 on Vista.
I have configured php.ini for both the mysql and mysqli extension, the 4 files php_mysql.dll, php_mysqli.dll libmysql.dll and libmysqli.dll are in the /php/ext directory and the path is correctly set. phpinfo() shows both mysql and mysqli as configured, loaded and driver version is same as mysql version (5.0.45).
When I try to connect with mysqli_connect, I am successful, when I try with mysql_connect it fails. I have tried reloading php with only mysql and that hasn't worked either. I have a lot of legacy pages I am hoping to not have to rewrite.
$link = mysqli_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
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.
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.
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 -
Edit: I am going to take a wild educated guess and say the problem is that your mysql_connect() statement is not being executed at all (probably because it is contained 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 connection to the mysql server using all default values.
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.