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 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化