0

Config.php :

define("DB_HOST", "127.0.0.1:1433");
define("DB_USER", "****");
define("DB_PASSWORD", "****");
define("DB_DATABASE", "name");

for some odd reason i keep on getting error:

mysqli::mysqli() [mysqli.mysqli]: (HY000/2005): Unknown MySQL server host '127.0.0.1:1433' (3) in filelocation/file.php on line X

line X = $this->con = new mysqli(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE);

the strange thing is that i also have an old mysql api running,

mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

which connects to the db without any problems whatsoever. note, that my MySQLi api was working and operational. This issue has only come to my notice since a week or two ago.

Question


Do I need to update my apache to run mySQLi again?

4
  • What version of PHP are you using? Also, have you checked in phpinfo() to see if you have mysqli? Commented Aug 26, 2015 at 13:15
  • did you try DB_HOST", "127.0.0.1 without the port number? Commented Aug 26, 2015 at 13:16
  • @b0s3, yes i have. I just get the same error but then to host '12.0.0.1'. Commented Aug 26, 2015 at 13:16
  • did u try using localhost instead of the ip and the port number Commented Aug 26, 2015 at 13:20

2 Answers 2

2

You need to define your port number in separate constant

define("DB_HOST", "127.0.0.1");
define("DB_USER", "****");
define("DB_PASSWORD", "****");
define("DB_DATABASE", "name");
define("DB_PORT", 1433);

And connect your database using parameter

new mysqli(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE,DB_PORT);
Sign up to request clarification or add additional context in comments.

1 Comment

yes, that did the trick. Strange though, since it used to work... msqli update perhaps ?
1
$mysqli = new mysqli("127.0.0.1", "user", "password", "database", "port number");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.