Problems, need help? Have a tip or advice? Post it here.
9 posts Page 1 of 1
I'm trying to install Couch on my local machine. I run Wampserver and I've changed config.php to include the correct database settings. I get the following warning:-

Warning: mysqli_error() expects parameter 1 to be mysqli, bool given in C:\wamp64\www\mdb\couch\includes\mysql2i\mysql2i.class.php on line 139
Cannot connect to database.

The database encoding is utf8_general_ci but if I specify the full definition in config.php I get another warning saying the encoding isn't recognised. By leaving
Code: Select all
define( 'K_CHARSET', 'utf8' );
I just get the first warning mentioned above.

Help please?
Hi,

The most relevant message is "Cannot connect to database".
That suggests that the creds you are supplying are not correct.
Please review.
I've checked and double-checked; even tried creating a new database and a new user - all result in the same warning. :?
OK. Let us try and troubleshoot the issue.

I am attaching a small script. Extract the 'test_db.php' file from the attached zip and place it within your 'couch' folder (it is important to place it within the 'couch' folder (or whatever you have renamed the folder to) so take care about this point).

Edit the file to add your database creds to it (the same that you provided in couch/config.php) -
Code: Select all
<?php

    // Enter your database creds here
    $db_name = 'couch_demo';
    $db_user = 'root';
    $db_password = 'root';
    $db_host = '127.0.0.1';
    ...

That done, now access this php file from your browser e.g. as
http://localhost/couch/test_db.php

If the creds are right, you should get an all OK message; else you'll get to see the error.
Please let me know what you get.

Attachments

Thanks for the help. Trying to run test_db.php results in the error:-

"Warning: include_once(C:/wamp64/www/mdb/includes/mysql2i/mysql2i.class.php): failed to open stream: No such file or directory in C:\wamp64\www\mdb\test_db.php"

Here is a screenshot from Windows Explorer showing the file path and the file where it should be!

Sorry, placed test_db in the wrong folder. Re-trying. Abject apologies!

Attachments

OK, thanks. Having screwed up my first attempt ( :oops: ), ran test_db.php from the correct folder. It gave two warnings:-

Notice: Undefined offset: 1 in C:\wamp64\www\mdb\couch\includes\mysql2i\mysql2i.class.php on line 44
Notice: Undefined variable: port in C:\wamp64\www\mdb\couch\includes\mysql2i\mysql2i.class.php on line 48

However, it also reported:-
"Connected to MySQL
Database selected
All OK"
OK. So, assuming, the same creds are being used in couch/config.php too, the most likely cause of them being rejected seems to be this - viewtopic.php?f=4&t=11723

Please open couch/config.php file in your text editor and make sure you are saving the file as 'UTF8 without BOM' (the editor will have this option somewhere). Also re-enter your creds as the previous ones would have been mangled.

As an alternative, copy the entire contents of couch/config.php and paste them into the 'test_db.php' file you have been testing. Next, delete the original couch/config.php file and rename 'test_db.php' to 'config.php'. This way we can be sure of using a file of correct format. Once again, make sure to re-enter the creds.

Hope this helps.
My editor is Visual Studio Code and file saving is set at utf8 without BOM - always has been!
I removed the old database (which was using MySQL) and set things up using MariaDB which is now the default database for Wamp.

I removed Couch and re-installed; reset the creds in config.php and all is well.

Thanks a million for your help and patience KK.
You are always welcome :)
I am glad the issue is resolved now.
9 posts Page 1 of 1