Basically open a cmd spend and run

>mysql --host= --port=1234 --user=myuser --password=mypassword mydb

I'm able to effectively connect with the remote mysql database.

But when I produce a php page on my small localhost that contains

$hostname = "";
$username = "myuser";
$password = "mypassword";
$dbname   = "mydb";
$connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");

I recieve the next error:

Error: could not connect to database

Can anybody explain what may be leading to the issue here?

mysql_error() => mysqlnd cannot connect to MySQL 4.1+ using old authentication

maybe inside your php.ini parameter sql.safe_mode is "1"?

sql.safe_mode boolean 

If switched on, database connect functions that specify default values uses individuals values instead of provided arguments. For default values see connect function documentation for that relevant database.

Auth troubles are a recognized problem with PHP 5.3 and older versions of MySQL. Take a look: