Forum

Thread tagged as: Installation

Warning: constant(): Couldn't find constant PERCH_DB_PASSWORD

I'm trying out the demo of perch and getting the error Warning: constant(): Couldn't find constant PERCH_DB_PASSWORD in \perch-test\perch\core\lib\PerchDB_MySQL.class.php on line 44 right after putting DB creds in on the setup process.

It's running on my windows 7 WAMP localhost as virtual host perch.dev

Any idea why this might be?

John Hobson

John Hobson 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is you perch/config folder writable by PHP?

Yeah, it's writable:

4 drwxr-xr-x 1 John 197121   0 Apr  5 11:44 templates/
4 drwxr-xr-x 1 John 197121   0 Apr  5 11:44 setup/
1 -rw-r--r-- 1 John 197121  55 Apr  5 11:43 runtime.php
0 drwxr-xr-x 1 John 197121   0 Mar 27 08:28 resources/
1 -rw-r--r-- 1 John 197121 138 Apr  5 11:43 index.php
4 drwxr-xr-x 1 John 197121   0 Apr  5 11:44 core/
4 drwxr-xr-x 1 John 197121   0 Apr  5 11:43 config/
4 drwxr-xr-x 1 John 197121   0 Apr  5 11:43 addons/
Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like it's only writable by you. What user does your web server run as?

Thanks Drew.

It's running as nt authority\system.

I did chmod 777 the directory via GIT bash and have also reapplied permissions through the windows GUI.

Screenshot: https://bit.ly/2orLuVB

Nothing has worked though I'm afraid.

I don't think it is permissions related. I just did a test and successfully wrote to a file in /perch using a php script:

$myfile = fopen("perch/test.txt", "w") or die("Unable to open file!");
$txt = "This is a test\n";
fwrite($myfile, $txt);
fclose($myfile);

I should also add that I have a great many wordpress sites running just fine on localhost.

PHP version is 5.5.12, apache is 2.4.9 and mysql 5.6.17

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't know anything about Windows, so I can't really advise how it should be configured. Are your config files being written?

I have finally got this working, but not without some faff.

At the point where it initially failed the config.php file existed but had not been written to, however the database had been setup with the perch tables.

I noticed that the form redirected to /perch/setup/license so I went to that page and was able to resume setup but then got the same error after entering my admin user details.

At this point the config file had been written, but an incorrect value was written for the password (which I had set as blank as using the root user):

define("PERCH_DB_PASSWORD", '$db_password');

I edited that to:

define("PERCH_DB_PASSWORD", '');

Additionally it seemed that the PERCH_ERROR_MODE was not defined anywhere so added this to the bottom of the config file (is that the right place for it?):

define('PERCH_ERROR_MODE', 'echo');

On re-sending the POST setup completed successfully and I was able to login to perch.

Looks to me like there's a couple of bugs there you might like to look at.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, yes, could've been the blank password that did it, or couldn't been the Windows environment. Sounds like something through the setup off and then left you in a weird state.

You don't ever need to define PERCH_ERROR_MODE, for example.

At any rate it shouldn't be an issue for me once I've satisfied myself that perch meets my needs as I'll be building sites on my linux hosting.

I may still occasionally work on localhost for more complex stuff where xdebug is helpful, but if the project is that complex, I probably wouldn't be using perch.

I have just had a similar issue trying to setup a new local Perch 3 install.

It seems the default behaviour during setup is to set PERCH_DB_PASSWORD to $db_password if an empty/blank password is provided.

This process creates a set of perch3_* tables in the database but does not actually populate the perch3_users table with the expected login, preventing log-in following completion. As detailed above, amending this field in the config.php file and re-posting to /perch/setup/license resolved the issue.

For reference, environment is Windows 7 using XAMPP.