douqin1932 2014-04-13 21:02
浏览 32
已采纳

kohana数据库异常[0]

I have a big problem with connecting to mysql database. I tried everything and nothing worked. If i try to connect on localhost with xampp to db on kohana (3.1.2), i get this error:

Database_Exception [ 0 ]: ~ MODPATH\database\classes\kohana\database\mysql.php [ 67 ]

but if i try run it on some server, it runs there and i dont know why, because everything is same (except db user and password). I thought that it can be with mysql config, but i dont know what there.

  • 写回答

2条回答 默认 最新

  • dqab0824 2015-07-03 04:54
    关注

    I just came across this problem and figured out what it was so even though this question is old, people having this problem should know the answer.

    Basically when you get this error its because your using a version of php 5.5+.

    mysql_connect(...) is a depreciated function starting in php 5.5 and above so the call in the framework is wrapped around a try/catch but the output from the catch doesn't give you any details about the error for whatever reason but if you remove the try/catch you'll see the real php error is simple saying mysql_connect is depreciated and will be removed in the future and to use mysqli instead.

    To fix this open index.php in your root and basically you need to change the error_reporting(...) call to tell it not to error on depreciation errors which you can do like so to report all errors except warnings and deprecations.

    error_reporting(E_ALL ^ (E_WARNING | E_DEPRECATED));
    

    Another fix is to change your database config file to connect via PDO instead of mysql.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?