Why does the exact same database credentials fail when I use mysqli_connect() but not when I use mysql_connect() in PHP [duplicate]

  mysql, mysqli, php

Yes, I know that all mysql_ functions have been deleted in PHP 7 and later and I have been using mysqli_ functions in all my later work.
But we have this old server that still uses PHP 5.2. So this database connection still works:

$dbh = mysql_connect("127.0.0.1:3305", "emailnot_dbe", 'SomePW1') 

But this will not connect:

$dbhi = mysqli_connect("127.0.0.1:3305", "emailnot_dbe", 'SomePW1', "SomeDB"); 

The error that mysqli_connect_error() shows is:

Unknown MySQL server host '127.0.0.1:3305' (2)

Even this fails:

$dbhi = mysqli_connect("localhost", "emailnot_dbe", 'SomePW1', "SomeDB");

The error that mysqli_connect_error() shows is:

Access denied for user 'emailnot_dbe'@'localhost' (using password: YES)

So it has no problem with mysqli_ functions, but the EXACT SAME creds that work with mysql_connect() will fail in mysqli_connect().
Does anyone have any ideas to share?

Source: Ask PHP

LEAVE A COMMENT