Welcome Guest, Not a member yet? Register   Sign In
getting error because of using php 7.2?
#1

(This post was last modified: 11-07-2019, 02:19 AM by richb201.)

I have moved my app from php 5.6 to php 7.2 because the dockerized version with xdebug was only avail in 7.2. Anyhow, I am getting this strange error. Is this due to the change from php 5.6 or due to some path error for the database or some problem with CI 3.11 and php 7.2? What should I look at first?


[docker://bitnami/php-fpm7:latest/]:php /opt/docker-substantiator/app/index.php

A PHP Error was encountered

Severity:    Warning
Message:    mysqli::real_connect(): (HY000/2002): Connection refused
Filename:    /opt/docker-substantiator/app/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 201

Backtrace:
File: /opt/docker-substantiator/app/application/core/MY_Loader.php
Line: 277
Function: database

File: /opt/docker-substantiator/app/application/controllers/Users.php
Line: 15
Function: __construct

File: /opt/docker-substantiator/app/index.php
Line: 317
Function: require_once



Database error: A Database Error Occurred

Unable to connect to your database server using the provided settings.
Filename: controllers/Users.php
Line Number: 15


Process finished with exit code 8

Now if I go look at line 15  in Users.php I see:

function __construct() {
    parent::__construct();     << line 15
    $this->load->library('form_validation');
    $this->load->library('session');
    $this->load->model('User');
    $this->load->helper(array('form', 'url'));
    $this->load->database();
    $this->_init();

}
proof that an old dog can learn new tricks
Reply
#2

(This post was last modified: 11-07-2019, 04:03 AM by InsiteFX.)

It's saying that your database settings are wrong.

If the php 7.2 you installed also installed MySQL then it must have changed
your MySQL password etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

I can see that. But what is strange is that when I don't go through phpStorm and type localhost directly into the browser, it works fine. How can that be? Perhaps in that case it is using the mySQL that is not in the docker container?
proof that an old dog can learn new tricks
Reply
#4

Or phpStorm is not finding it through it's database config.

Check the phpStorm database settings.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 11-08-2019, 06:39 AM by richb201.)

I contacted the phpStorm support team. They stated that there is nowhere in phpStorm where I would set this. Here is the error I am getting:

Severity:    Warning
Message:    CI_DB_mysqli_driver::db_connect(): Property access is not allowed yet
Filename:    /opt/docker-substantiator/app/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 201


Backtrace:
File: /opt/docker-substantiator/app/application/core/MY_Loader.php
Line: 277
Function: database

File: /opt/docker-substantiator/app/application/controllers/Users.php
Line: 15
Function: __construct

File: /opt/docker-substantiator/app/index.php
Line: 317
Function: require_once

I get about 7 or 8 of this same exact error, and the  finally I get to this line:
if ($this->_mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, $socket, $client_flags))
which has this comment right below it:
// Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails

and this line fails with this error:

Database error: A Database Error Occurred



Unable to connect to your database server using the provided settings.

Filename: controllers/Users.php

Line Number: 15




Process finished with exit code 8
proof that an old dog can learn new tricks
Reply
#6

(11-08-2019, 06:30 AM)richb201 Wrote: I contacted the phpStorm support team. They stated that there is nowhere in phpStorm where I would set this. Here is the error I am getting:

Severity:    Warning
Message:    CI_DB_mysqli_driver::db_connect(): Property access is not allowed yet
Filename:    /opt/docker-substantiator/app/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 201


Backtrace:
File: /opt/docker-substantiator/app/application/core/MY_Loader.php
Line: 277
Function: database

File: /opt/docker-substantiator/app/application/controllers/Users.php
Line: 15
Function: __construct

File: /opt/docker-substantiator/app/index.php
Line: 317
Function: require_once

I get about 7 or 8 of this same exact error, and the  finally I get to this line:
if ($this->_mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, $socket, $client_flags))
which has this comment right below it:
// Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails

and this line fails with this error:

Database error: A Database Error Occurred



Unable to connect to your database server using the provided settings.

Filename: controllers/Users.php

Line Number: 15




Process finished with exit code 8

NOTE: I managed to solve this. I think the issue was with the Docker version of mySQL. 
proof that an old dog can learn new tricks
Reply
#7

(This post was last modified: 12-09-2019, 09:28 PM by John_Betong.)

Here are two CodeIgniter4 declare(strict_types=1); modifications that may be relevant.

The changes were necessary to connect to the MySQLi database:

file: system/Database/Query.php
PHP Code:
public function getStartTime(bool $returnRaw falseint $decimals 6): string
{
  if ($returnRaw)
  {
    # JOHN MODIFIED
    # return $this->startTime;
    return number_format($this->startTime$decimals);
  }

  return number_format($this->startTime$decimals);


file: system/Database/MySQLi/Connection.php
Code:
public function connect(bool $persistent = false)
{
// Do we have a socket path?
if ($this->hostname[0] === '/')
{
  $hostname = null;
  $port     = null;
  $socket   = $this->hostname;
}
else
{
  $hostname = ($persistent === true) ? 'p:' . $this->hostname : $this->hostname;
  $port     = empty($this->port) ? null : $this->port;
  # JOHN MODIFIED
  # $socket = null;
  $socket   = '';
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB