Welcome Guest, Not a member yet? Register   Sign In
MySql / MariaDB Connection problem
#1

Hi

I just installed 3.17 version. Prior to this one I have been using 2.2 and had no problems with connection to mysql. With this  new install I did configure  database.php  file to connect to my mysql  server.


$active_group = 'default';
$query_builder = TRUE;

$db['default'] = array(
    'dsn'    => '',
    'hostname' => 'localhost',
    'username' => 'root',
    'password' => 'pass',
    'database' => 'test',
    'dbdriver' => 'mysql',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);


I have also configured the autoload.php file to autoload  a mysql  database library.


$autoload['libraries'] = array('database');



When I run 3.17 codeigniter,  the  'database' library generate a Call to undefined function mysql_connect() error

An uncaught Exception was encountered
Type: Error
Message: Call to undefined function mysql_connect()
Line Number: 136
Backtrace:
File: /srv/www/htdocs/CI_TEST/index.php
Line: 315
Function: require_once





When I remove the 'database'  library element from an array,

$autoload['libraries'] = array();

the standard welcome codeigniter page is generated.


Welcome to CodeIgniter!
The page you are looking at is being generated dynamically by CodeIgniter.
If you would like to edit this page you'll find it located at:

Code:
application/views/welcome_message.php

The corresponding controller for this page is found at:

Code:
application/controllers/Welcome.php

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.

Page rendered in 0.0104 seconds. CodeIgniter Version 3.1.7



I have tried to initialize the database class manually, $this->load->database(); , but the error remains.



I have this problem on the OpenSUSE Tumbleweed new install platform. The database is MariaDB, which is MySQL compatible. Installed PHP version is 7.
I have no problem accessing this database using phpMyAdmin or MySQL Workbench with
  
    hostname => localhost
    username => root
    password => pass


credentials. They are exactly the same as set in database.php config file. I can access this database locally or remotly, so sever's firewall and allowed services are not an issue. Tried with firewall off and no difference.

 

Could you assist me to sort out  this problem?

Many Thanks
[Image: cleardot.gif]

[Image: cleardot.gif]
Reply
#2

MySQL are deprecated as of PHP 5.5 and removed in PHP 7.0 use mysqli or pdo instead.
Code:
'dbdriver' => 'mysqli'
Reply
#3

(01-18-2018, 05:02 AM)jreklund Wrote: MySQL are deprecated as of PHP 5.5 and removed in PHP 7.0 use mysqli or pdo instead.
Code:
'dbdriver' => 'mysqli'

And that's also the default value ...

But I am replying for another reason: It's 3.1.7, not 3.17 - that dot is there for a reason.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB