# Mysql, PHP Access Denied (Guestbook used to work)



## king-daddy (Mar 22, 2017)

Now on Windows 7...
1995 I started a personal domain for grand kids scrap book. Each kid has a subdomain.

Later I had need for a guestbook on ONE of them, and I had help from workplace peers to get it working. About 10 years later (separate story line) it was no longer used. Now his mother needs it again. I was informed it no longer works, so I checked:

This is link to the gueastbook
http://rnc3.com/guestbooks/dylan/index.php

*Warning*: mysql_connect(): Access denied for user 'clackey3'@'localhost' (using password: YES) in */home4/clackey3/public_html/guestbooks/dylan/lib/mysql.class.php* on line *30*
*Connection Error*
MySQL Error : Connection Error
Error Number: 1045 Access denied for user 'clackey3'@'localhost' (using password: YES)
Date : Tue, March 21, 2017 20:16:04
IP : 136.56.0.65
Browser : Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Referer : http://rnc3.com/dylan/main.htm
PHP Version : 5.4.45
OS : Linux
Server : Apache
Server Name : rnc3.com

The Hosting provider has upgraded system at least two times, and I never checked the guest book. There are no other guestbooks. I am guessing there is an environmental change that needs attention.

Of course I do not have a database on a home machine. The guestbook is only on my hosting provider.

Is there a better place for me to seek help?


----------



## colinsp (Sep 5, 2007)

MySQL calls are now deprecated and as a result some hosts have moved on to later versions of PHP that no longer support those calls. I suspect this may be your issue. As a result the application will need to be rewritten to use MySQLi or even better PDO calls to the database. You may be better off getting a new guestbook script.


----------



## JiminSA (Dec 15, 2011)

The advice offered by Colin, is well worth your consideration and action.
However, I rather think that your website's host, would have informed you if they were abandoning the deprecated MySql in favour of MySqli.
What I think may have happened over the years, is that your Adminstrative Rights for username clackey3 may have been lost.
To check the username/database setup for your site ...
1. Login to your Host's website and navigate to the Control Panel (method varies from host to host).
2. Click on MySql Databases.
3. Scroll down, looking for MySql Users and see if username clackey3 is there. If it's not there you should add it, taking note of the password you use (for later use).

If that was the case you must update the connection code in your website script to reflect the new password. Report back and we'll help ...


----------



## king-daddy (Mar 22, 2017)

Morning adventures with the hostgator very new control panel,
when I selected "MySQL Databases" I was prompted to CREATE userid and password. Past that point, all was my normal expectations. Exploring by "feel" I determind all the databases are there and user is correct. I started prowling though folders wondering if I could find where the password is coded. Whin I click on PHP files, it nicely opens Expression web, but I promptly felt like I stepped in some "doo-do".

I created some screen captures, and I copied the database code folder to a place where I can let you have access via a folder listing.

Screen captures:
D:\rnc3.net\public\screenshots\dylan_guestbook

And the files. I cripled the index so it would provide a listing.

http://rnc3.com/projects/sandbox/dylan/


----------



## JiminSA (Dec 15, 2011)

king-daddy said:


> Exploring by "feel" I determind all the databases are there and user is correct.


Are you saying that you found user clackey3 - if so did you change the password?


----------



## JiminSA (Dec 15, 2011)

Thank you for your efforts to get me the php files. However the browser is not able to show server-side php files. So your efforts were wasted.
However, if you have access to the site via Filezilla (FTP up/download program), maybe you should download the site to your hard drive and we shall search for the mysql connect script ...


----------



## king-daddy (Mar 22, 2017)

Still pondering the user, password; I don't recall ever sing 'local host' in the past, but I do understand with the virtual domain server.
I added 2 new users today. If I can find where the login credential are entered, it will be helpful.


----------



## king-daddy (Mar 22, 2017)

I found dylan-20070416.sql with password field of 472489057a63f161 (encrypted password?) Looks like encrypted date, or something not human happy.
AHA! I tripped over:
config.inc.php....

$GB_DB["dbName"] = "guestbk1_db1000172";
$GB_DB["host"] = "127.0.0.1";
$GB_DB["user"] = "clack1_u1000172";
$GB_DB["pass"] = "buick1";

...which is the password I recall.

What can I do with this information now, to use it for helping diagnose my problem? It looks obvious, but I wanna ask.


----------



## king-daddy (Mar 22, 2017)

The user clackey3 is the user in the Shared_Server to which domain "rnc3.com" is assigned. Today I learned that when clicked to enter, " I see that 'add a user' to MySql, the user name is restricted to 7 characters. When I proceed into to "MySql Databases," I select: 'clackey3_dylangb' database.

As I continue to prowl and learn, I think the Access denied error message is logging into virtual "local host" named clackey3... just guessing at this point. Maybe 'data base access' is a new level of security? I'm gonna ask support about it.


----------



## colinsp (Sep 5, 2007)

See this article about creating users of a database in cpanel. Create a new user with all permissions and then put that new users id and password into your database connection script instead of the existing one. All databases will be access as just plain localhost.


----------



## king-daddy (Mar 22, 2017)

king-daddy said:


> The user clackey3 is the user in the Shared_Server to which domain "rnc3.com" is assigned. Today I learned that when clicked to enter, " I see that 'add a user' to MySql, the user name is restricted to 7 characters. When I proceed into to "MySql Databases," I select: 'clackey3_dylangb' database.
> 
> As I continue to prowl and learn, I think the Access denied error message is logging into virtual "local host" named clackey3... just guessing at this point. Maybe 'data base access' is a new level of security? I'm gonna ask support about it.


After creating two new3 user / password trials; and nothing changed... my curren conclusion, BIG picture, I know what happened, but I don't know hwat "little Flag" makes the database become integrated with the system's domain.

I copied (FTP) the Guestbook Directory to another similar domain I have. There are no databases on that one. The error id EXACTLY the same.

What I think...
When new systems were installed, and mw data was copied to the nes system, the dabase os there , but some DBA activity totell the system "here I am", never happened. That is probably my responsibility. It must be a step in the original "setup and install" of "Advanced Guestbook 2.3" several years ago.

Unless I can find details how to let the system to know the guestbook database is available and named, I will have to export data, reinstall/rebuild it, and import.

That sound like fun for a DBA with a little confidence (sheepish grin).


----------



## king-daddy (Mar 22, 2017)

Whew! Hostgator support. a little over 2 hours on CHAT, and went to 3rd level support. I have no detail... but no database could be reached at all.

So with me of the detail I eventually shared... with support:
The original DB was created in 2001 with a guestbook package using Mysql and PHP available at that time.

Adding users from cpanel, adding database, export data and sql, all worked from cpanel, but no access through the PHP code. 

Several upgrades of hardware and facilities since then... and last DB data was in 2013.

I have no more useful information.


----------



## king-daddy (Mar 22, 2017)

Sorry, I forgot to say... all is working not:
Hot link to guestbook
http://rnc3.com/guestbooks/dylan/index.php


----------



## colinsp (Sep 5, 2007)

Given what you have said it looks like over the course of the years your database has been lost. The easiest way from here will be to get yourself a new guestbook script and start from there. If you have Softaculos installed as part of your hosting there are several scripts included. If not take a look at Hotscripts for instance.


----------

