duanjiong5686 2012-11-27 02:19
浏览 231

PHP mysqli连接到远程数据库

Trying to connect to a database that is not on the same host as my site for the first time and not having much luck. The DB is on a godaddy host and I have configured it to allow remote access:

$dbc = mysqli_connect($db_host,$db_user,$db_pass,$db_name);

if (!$dbc) {
    die('Connect Error: ' . mysqli_connect_error());
}

and I get the following on page:

Warning: mysqli_connect() [function.mysqli-connect]: [2002] Connection timed out (trying to connect via ‘mydbhostname:3306) in ‘path’ on line 3

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): Connection timed out in ‘path’ on line 3

Connect Error: Connection timed out

Anything I need to look for on my end or something in the script that could be causing this?

EDIT: well it appears everything works when I use mysql, but not mysqli...and mysqli is enabled on the server.

  • 写回答

3条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示