Welcome Guest, Not a member yet? Register   Sign In
Mysqli on WAMP, error - connection attempt failed
#1

Hello Everybody,

I am working on my first Codeigniter project. Recently I migrated this project to Windows 10 from Windows 7, in Windows 7, I was working with manual installation of Apache, PHP, Mysql but in Windows 10 I installed WAMP.

And I am getting following error message in this new setup. The page keeps on loading and loading and then fails with the error message. The mysqli extention is installed and loaded.


Quote:A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Filename: mysqli/mysqli_driver.php
Line Number: 135

Further done the page this is the message I get :
Quote:Unable to connect to your database server using the provided settings.



If I change 'dbdriver' => 'mysqli', part of the config to 'dbdriver' => 'mysql', then it works but shows a warning of deprecated mysql extension.

Code:
$db['default'] = array(
   'dsn'   => '',
   'hostname' => 'localhost',
   'username' => 'root',
   'password' => '',
   'database' => 'studentx',
   'dbdriver' => 'mysqli', // This one here.
   'dbprefix' => '',
   'pconnect' => FALSE,
   'db_debug' => TRUE,
   '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 checked my phpinfo and the mysqli is installed. I checked it with the following code and it is working.

Code:
<?php
$mysqli = new mysqli("localhost", "root", "", "myDatabase");

/* check connection */
if ($mysqli->connect_errno) {
   printf("Connect failed: %s\n", $mysqli->connect_error);
   exit();
}

/* check if server is alive */
if ($mysqli->ping()) {
   printf ("Our connection is ok!\n");
} else {
   printf ("Error: %s\n", $mysqli->error);
}

/* close connection */
$mysqli->close();
?>

/*** Results in : Our connection is ok! ***/


1. wamp icon > php > php_extensions > php_mysqli
2. extension=php_mysqli.dll in php ini is un-commented.
3. The extension_dir" c:/wamp/bin/php/php5.5.12/ext/ is correct for my php version install.
4. I tried it with the fresh install of the codeigniter, simply adding $this->load->database ( ) to the default controller triggers the same error.

I created a virtual host for this project do here is info about it.

HOST file :


Code:
127.0.0.1       localhost
::1             localhost
    
127.0.0.1       myProject
::1             myProject

Apache httpd-vhosts.conf file :

Code:
<VirtualHost *:80>
   ServerAdmin [email protected]
   DocumentRoot "c:/wamp/www"
   ServerName localhost
   ServerAlias localhost
   <Directory  "c:/wamp/www">
       Options Indexes FollowSymLinks
       AllowOverride All
       Require local
   </Directory>
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin [email protected]
   DocumentRoot "c:/wamp/www/myProject/www"
   ServerName myProject
   ServerAlias myProject
   ErrorLog "logs/myProject-error.log"
   CustomLog "logs/myProject-access.log" common
   <Directory  "c:/wamp/www/myProject/www">
       Options Indexes FollowSymLinks
       AllowOverride All
       Require local
   </Directory>
</VirtualHost>

Project .htaccess file :

Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  


<Files "index.php">
AcceptPathInfo On
</Files>  
</IfModule>

<IfModule !mod_rewrite.c>

ErrorDocument 404 /index.php
</IfModule>

So, how do I make mysqli work for codeigniter ?
Reply


Messages In This Thread
Mysqli on WAMP, error - connection attempt failed - by StudentX - 12-18-2015, 06:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB