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 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题