【问题标题】:Error with connection with adodb in php在 php 中与 adodb 连接时出错
【发布时间】:2017-07-18 16:36:54
【问题描述】:

您好,尝试连接到数据库,但我不能这样做,我使用 laragon 运行程序并显示此错误。 数据库连接是 adodb 和 mysql。 感谢帮助。

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADODB_Cache_File has a deprecated constructor in C:\laragon\www\FacturaElectronicaAlumgo\sistema\adodb5\adodb.inc.php on line 233

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADOConnection has a deprecated constructor in C:\laragon\www\FacturaElectronicaAlumgo\sistema\adodb5\adodb.inc.php on line 327

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADORecordSet has a deprecated constructor in C:\laragon\www\FacturaElectronicaAlumgo\sistema\adodb5\adodb.inc.php on line 2854

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; ADORecordSet_array has a deprecated constructor in C:\laragon\www\FacturaElectronicaAlumgo\sistema\adodb5\adodb.inc.php on line 3872

Fatal error: Uncaught Error: Call to undefined function mysql_pconnect() in C:\laragon\www\FacturaElectronicaAlumgo\sistema\adodb5\drivers\adodb-mysql.inc.php:383 Stack trace: #0 C:\laragon\www\FacturaElectronicaAlumgo\sistema\adodb5\adodb.inc.php(588): ADODB_mysql->_pconnect('localhost', 'root', 'black44265769', 'cal24412_dte') #1 C:\laragon\www\FacturaElectronicaAlumgo\sistema\conexion.php(3): ADOConnection->PConnect('localhost', 'root', 'black44265769', 'cal24412_dte') #2 C:\laragon\www\FacturaElectronicaAlumgo\sistema\validar.php(8): include('C:\\laragon\\www\\...') #3 {main} thrown in C:\laragon\www\FacturaElectronicaAlumgo\sistema\adodb5\drivers\adodb-mysql.inc.php on line 383

【问题讨论】:

    标签: php mysql adodb-php


    【解决方案1】:

    什么PHP版本?由于“已弃用”消息和最后一个“致命”错误,我在此处(可能)假设为 7.x。

    这是一个两部分的问题......

    1. 已弃用:

      PHP 已更改为使用 __construct() (两个前导下划线)作为构造函数,而不是与类本身同名。有关详细信息,请参阅PHP 4 style constructors 部分(页面上的第一部分)。

      例如:在ADOConnection has a deprecated constructor... 的文件中,构造函数可能如下所示:

      ADOConnection( ... ); // constructors with or without parameters
      

      ...但所有这些都可以替换为:

      __construct( ... );
      

      您可以在本地进行更改以解决已弃用的消息。

    2. 致命错误:

      在 PHP 7.x 中,基于 mysql_* 的函数是 删除。见this API info

    【讨论】:

    • 感谢您的回答,您解决了 dreprecate 错误,现在我尝试使用相同的 api 信息解决致命错误,您的回答对我帮助很大,非常感谢 PD:我不习惯工作PHP 和我在公司的系统有很多错误,所以对我来说有点困难,再次感谢
    • 要解决其他问题,您将无法使用mysql_*。您将需要使用mysqli_*(注意尾随的i)或PDO 处理。
    • 您没有指定正在运行的 ADOdb 版本。 PHP 4 的构造函数在 5.20.2 版本中被移除,我建议你将你的库代码升级到最新版本。
    • 关于未定义的 mysql 函数错误,请确保您的代码使用 'mysqli' 驱动程序初始化数据库对象(查找 NewADOConnection 或 ADONewConnection 函数调用)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    • 2010-11-28
    • 1970-01-01
    • 2015-11-04
    • 2021-06-28
    相关资源
    最近更新 更多