MAMP (Mac) Execution Error - Refused to connect


Downloaded PHPPickem code. Installed on my Mac. Now I want to begin running it, starting with an install.php.

The files are in the default folder: Applications > MAMP > htdocs

MAMP is running. The Apache and MySQL servers are running.

If I understand Pick 'Em correctly the installer file is in a subdirectory install > install.php

In my browser I am entering: http://localhost/install/install.php
Getting the error below.

What am I doing incorrectly?


This site can’t be reached

localhost refused to connect.




Well, Never used MAMP before. But, I am guessing it is just like WAMP.
So, you should have a panel running on WAMP where you turn things on and off.
In there, you should see where you can go to your localhost.
Then, under localhost, you should be able to see your folder for your website, and should be able to get into your install folder. BEFORE you do that, you must edit the config file and set up your connection to the database.

But, also, you access it from your browser like this: localhost:8888/yourhtdocsdirectory
So, that is localhost, then a colon then your port number which is most likely 8888 and then your MAMP HTDOCS folder. Then your folder name of the website. Something like that.
In some MAMP setups, you just do the localhost and port and then your website folder.

Good luck…


Thanks. Good reply… Included the solution plus other information that may be of value down the road.

Got the following page that begins with:

PHP Pick 'Em Installation

> Step 1 - Edit Config File



Yes, so you have it working. The Config file should have been done before you started.
You must put in your local-host, username and password and db name for your local database.

Now, do you have a server other than Mamp? Just curious how you are planning to serve it out to others…


Good morning ErnieAlex,

Yes. I have my own domain, Lunarpages is the host provider and hosting includes necessary PHP and db functionality.

Config file… Ah, yes, this topic raises a question. :slight_smile:

I like telling people, “I am lazy and will work hard to be that way.”

In this case it pertains to developing on my home Mac, then uploading the files to the web site, i.e. production.

But! I don’t want to edit the config file going back and forth. And, being “lazy”, I don’t want to keep two versions, one for development, one for production.

The quick solution is to have IF coding to detect some property of the host server and assign values accordingly.

Would DB_HOSTNAME be ‘localhost’ for both? I am guessing yes, but don’t know why (and that bothers me).

I can set DB_USERNAME, DP_PASSWORD, and DB_DATABASE to be the same.

On the home server there is no prefix. Will a pair of single quotes suffice? Or, a space between them? (Space is a character vs 0 length with the quotes together, but, then does the interpreter replace double quotes with a single?

SITE_URL will be different for development and production. Not sure how it works on the website. My domain is represented, in the file manager, as public_html. I would guess that is equivalent to “localhost” and the filepath would match where I place the pickem code. Example: public_html > nflpool > pickem > (Pickem files and subfolders)
define(‘SITE_URL’, ‘http://localhost/nflpool/pickem/’);

Back to the IF question. I anticipate the 1st 4 defines can remain as is for both. Followed by
if (some server or other attribute = ‘the home/mac value’ {
// set values for development PREFIX and SITE_URL
} else {
// set values for production

// Database
define(‘DB_HOSTNAME’, ‘localhost’);
define(‘DB_USERNAME’, ‘dbadmin’);
define(‘DB_PASSWORD’, ‘Nasa~6272’);
define(‘DB_DATABASE’, ‘nflc1’);
define(‘DB_PREFIX’, ‘edasse2_’);

define(‘SITE_URL’, ‘http://localhost/personal/applications/phppickem/’);


Good evening ErnieAlex,

The config.php file is edited. Example is below (some credentials are changed for security).

When I click to proceed to steps 2 and 3 get the following error. Have been googling, searching, editing … no luck figuring out why

PHP Pick 'Em Installation

Step 1 - Edit Config File

Step 2 - Install Database

Step 3 - Complete

Could not connect to database.

Please check your config file and make sure your database credentials were entered correctly, and that the file was saved.

This is my code - running this on my home/development environment

// Database
define(‘DB_HOSTNAME’, ‘localhost’);
define(‘DB_USERNAME’, ‘dbadm’);
define(‘DB_PASSWORD’, ‘dbpsswrd’);
define(‘DB_DATABASE’, ‘nflc1’);
// define(‘DB_PREFIX’, ‘edasse2_’); // Live
define(‘DB_PREFIX’, ‘’); // Home - Single quotes, there is no prefix (that I know of)

// define(‘SITE_URL’, ‘http://localhost/personal/applications/phppickem/’); // Live
define(‘SITE_URL’, ‘http://localhost/’); // Home


Well, what I normally do is create a test folder on my live server and place the site in there.
But, most programmers keep an offline version for testing and an online version for live usage.

You just need to create a different config file for both. The live one points to the live system’s mysql
and the test one to the local version. Either way works.

Now, if you are getting Can’t connect to database errors, then one of the items are not working. Most likely
the user name or password. So, make sure you created a user account in the MySQL’s phpadmin panel.
You need to log into that and create a valid user that is allowed to connect to the database. (Local one)

Hope that makes sense…


I’m a lazy programmer and I just do the following

if (filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_URL) == "localhost") {
    define('DATABASE_HOST', 'localhost'); // usually localhost
    define('DATABASE_NAME', 'cms');
    define('DATABASE_USERNAME', 'username');
    define('DATABASE_PASSWORD', 'password');
    define('DATABASE_TABLE', 'users');
} else {
    define('DATABASE_HOST', 'remote_database_host');
    define('DATABASE_NAME', 'remote_db_name');
    define('DATABASE_USERNAME', 'remote_username');
    define('DATABASE_PASSWORD', 'remote_password');
    define('DATABASE_TABLE', 'users');

that way I don’t have to write separate configuration files, plus I also do this with error reporting that is I have it turned off on the remote server.


Oh I meant to mention that all I do is this when I want to run the local server web page

http://localhost/SliceofTechnology/ (You don’t have to do following if you do it this way)

I think if you do the following

that you have to do something like this
define(‘DATABASE_HOST’, ‘localhost:8889’); // usually localhost

to access mysqli locally, but the way to check is to do phpinfo();
I know I was scratching my head for a long time when I first started using MAMP


Strider64 - Thank you for the tip.


Was not able to connect to the database on my localhost (MAMP). Double/triple checked everything. I thought it might be that there is no prefix on my home MAMP database. Used ‘’ (a pair of single quote marks) so the statement to replace ‘nflp_’ with the DP_PREFIX, which is no characters/0 character length string.

So, now I am attempting to do this online (live environment). In my browser I am entering what I think should execute the installer (the domain name and first subdirectory names have been changed (as a meager) security precaution:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.4.34 (cPanel) OpenSSL/1.0.2o mod_bwlimited/1.4 Resin/4.0.53 Server at Port 80


I installed the Pickem package on my live server (Godaddy) and on a local Wamp system.
Both worked without flaws. This is the process I used:

1 - downloaded the package (noting that it is many years old and not supported anymore from the author)
2 - unzipped it.
3 - altered the config file as the instructions mentioned to connect to my database.
( Left the nflp_ prefix as-is so I can use the table for other things, too. NFLP stands for NFL-Pickem prefix!)
4 - went to the domain-name/install folder (not putting in the index.php name) and it worked
5 - went to the local-host using my Wamp panel, then the pickem folder then install folder and it worked.

I did have a huge problem with 500 errors. It was due to a very messed up htaccess file in the root folder.
******** So, for now just delete the “htaccess” file from your server, both the localhost AND the live versions
and I bet the errors go away. Just make 100% sure you delete those on the servers and that you
also edit your config file to let it connect to your DB correctly ! *********
Should work for you!


One further thing. Remember earlier in the thread, I mentioned the base package was very good as far as covering most things, but, not very secure and a bit hard to alter. A lot of it is easy, but, expect some work and you are running out of time… LOL

One part is the entry of games. I added game numbers to it so they will stay displayed in order and easier to alter them. Made the entry simpler adding in set times for the games in a drop-down, etc. And added in a lot of security, mostly just filtering the inputs from the forms. Have not had time to review the password encryption on it, but, bet it needs attention, too. So, you have your work cut out for you. First things first, remove the htaccess file and it will work. I am studying that file to replace it soon and will send you a working version later on…


Good afternoon ErnieAlex,

Thanks for the info, especially the “running out of time” reminder! (ha,ha) The game is on!

Those distractions, a result of moving from NY to FL, are finally being tasks of the past and I am able to sit down and focus on this more. The game is on! (Oh! I already said that.)

I am confused about the database. The instructions indicated to create the database before running the scripts. When I create a database in the live environment, using phpMyAdmin, it automatically assigns a prefix based on my server credentials. When I create it at home, again phpMyAdmin, there is no prefix. From my MS SQL Server experience the prefix is the ultimate Admin level.

  1. Does the script create the database? I can’t imagine it can have the authority to do it.
  2. If I create the database, can I specify a prefix?

Well, off to “trial and error” getting Pickem up and running, using your advise as guideline.



Perhaps we are confused on terminology…

In the Pickem template or website system, they talk about prefix meaning something that is used in front of the database tables so you can know what they are. So, let’s say you create a database and call it “ed” Or “pool” or whatever your heart desires. Inside the database, you create tables. One for each major part of your system. Like users, game-schedules, winner’s list, etc. These tables are given names and are used all thru your website wherever needed. Such as the user’s table being used to long in or showing the schedule of games for the week. I think you understand that, right !

Now, Pickem, creates them with the “prefix” you request. I suggest just leaving it as “nflp_”. What this does in the install section is to create the tables for you with all of the fields in place in them set up as the Pickem code currently needs. Such as in the games schedule, it basically has home team, visitor team week number and date of the game. Not much else is needed for that table. I did add in a game number and used that to keep them in order better. I used that number also to add in a tie-breaker combined-score on the Monday night games. (It only shows the entry field if on Monday and if it’s the last game of the week.

So, “PREFIX” in this case is a name that the automatic install process creates in front of each table name it creates. You can remove it and not use it, but, let’s say you wanted two pools, one for NFL and work friends and a different one for personal or family friends. You could use two different prefixes and have two pools in one database. If only one pool is involved, the prefix means nothing much. BUT, it does when you create a query or alter one. You need to know the table name you are accessing.

1, 2:
So, you create the database with a username and password and place that info inside the config file. The install script creates the tables inside of it using the prefix you give and all the basic setups for fields in each table, field-type such as text, integer, etc and any other things to set all the tables up and make them usable. Don’t bother using a prefix when you create the database. It is just used in the table names and the install will handle that.

Hope that explains what this means. Next question?


I’ve been struggling trying to make progress.
Like you indicated, I renamed .htaccess and got to that “first page”.
Clicking to proceed to step 2 and 3 got me to the Unable to Connect to the database.
I have been trying everything I can think of get the config correct.

Finally, I decided to back up, remove the database, and start over. Now the poop hit the fan. This is on the live environment, Lunarpages web hosting.

phpMyAdmin - I can see the databases, but I don’t see the Users tab, nor can I delete nflc1 (the one I created).
When I click to view Privileges I get “No Privileges” for nflc1 and the db I have been using!

I can see that I am auto logged in as edasse2@localhost.
*That is what has always been the case, hence, why I did not know about the prefix information you provided.
*I don’t know how to change the prefix. As far as I knew it was automatically assigned. But, we have a bigger problem.

I need to be able to perform db admin tasks.
At this time, let’s remove the database then add it back, and attempt to specify the prefix, nflp_

Any suggestions?


P.S. Meanwhile I am going to search for a (hopefully free) online NFL picking site that will allow me to download the players’ picks. Or similar ability such as a Pick Sheet with everyone’s picks that I can copy/paste into Excel and “massage” the data for my needs. That will be my backup, if needed.


Well, I am leaving shortly and will be gone for several hours, most likely after midnight EST.
But, if you want me to look at your server on Lunarpages, send me the login info in a private message.
If you don’t want to give me access to the site, we can still work here.

First, on the phpMyAdmin, you just need to create one database called anything you wish.
Then, create a user that can get access to it. This username will have a password. These will be needed to be added into the config file in the Pickem files. Once you alter the config file with the database name, username and password, you copy that config file to the server. Then, you should be able to run the install process which will set up all the tables as needed.

Do you follow this part so far?

Next, once you have created a database, you should be able to see the new database in the phpMyAdmin list of databases. Tables inside it are not really important at this point. But, if you did get all the correct tables installed, they should show up. Unable to Connect to the database simply means that one of the three items (database, username or password names) are invalid. If you can see the database in the phpMyAdmin panel, then, you are 90% there. Most likely, the user you set up was attached to a database that you deleted and is still trying to get to the old one. Normally, if starting over, you have to remove all users that are allowed to access the database, then remove the database. So, my wild guess is that you just do not have a valid database set up, or the username is not linked to it.

Not sure if all this helps…