Search code examples
phpmysqladodb-php

Error with connection with adodb in php


Hello a trying connect to database and i cant do this , i run the program with laragon and show this errors. the database connection is with adodb with mysql. Thanks for help.

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


Solution

  • What PHP version? I'm assuming 7.x here (possibly) due to the 'deprecated' messages and the last 'fatal' error.

    It's a two part matter...

    1. The deprecated:

      PHP has made a change to use __construct() (two leading underscores) as the constructor instead of having the same name as the class itself. See the PHP 4 style constructors section (first section on the page) for more information.

      For example: In the file to ADOConnection has a deprecated constructor... the constructor likely looks like this:

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

      ...but all of those can be replaced with:

      __construct( ... );
      

      You can make that change locally to resolve the deprecated messages.

    2. The fatal error:

      With PHP 7.x, the mysql_* based functions are removed. See this API info.