开发者

Mysqli: Unknown server host

Seems like this is a pretty common error, but I can't work it out. I'm running PHP 5.3.1 towards an external MySQL server 5.5.8 - both installed with Phpmyadmin and running Windows Server 2k8R2.

When I try the following:

   $connection = new mysqli("myhost.com:3306", "myUser", "myPwd", "myDB");
   $result = $connection-开发者_如何学C>prepare("SELECT * FROM tt_staff
                           WHERE crew_type = ?
                           AND inaktiv_vakt = 0
                           ORDER BY ansvarlig_vakt DESC, crew_type, navn_vakt");
   $result->bind_param("s", $value);
   $result->execute();
   $result->bind_result($value, $name);

I get the " Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2005): Unknown MySQL server host (...)"

I made sure that the Mysqli is enabled in the php.ini on the DB-server, but that's also all I've done as I've been told this should work out-of-the-box. Since this is the first time I'm working with prepared statements there very well might be a simple typo error in there some place.


The problem is that MySQLi does not accept the port as part of the hostname but as a separate parameter. So I think this is how you should open your connection:

$connection = new mysqli("myhost.com", "myUser", "myPwd", "myDB", "3306");

Or perhaps, do not give the port at all because 3306 is the default one.


Check the Privileges for your user ('myUser') on the Database. Make sure the privileges allow connections thru '%' (or just your IP), not just 'localhost' (127.0.0.1). Then make sure to "reload priviliges'.

BlockquoteNote: phpMyAdmin gets the users' privileges directly from MySQL's privilege tables. The content of these tables may differ from the privileges the server uses, if they have been changed manually. In this case, you should reload the privileges before you continue.


mysqli cannot find the database server, you need to check that domain and port number are correct

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜