
If you have any issues with this please attempt to break it up into smaller pieces while reviewing the PDO documentation.
MAMP UPDATE DB PASSWORD CODE
Since this is 100% php code we do not need to add a closing php tag Since we had an issue connecting to the database we should log it, so we can review it.Įrror_log("Database Error". user's do not need to know the specific error that is causing a problem for securityĮcho "Oh, sorry there was an issue with your request please try again." Show that there was an issue connecting to the database. If this does not worth catch the exception thrown by PDO so we can use it. If we are successful show it :D for the test page, if this is for production you should not show this.Įcho "Database connection was successful." $MYDB = new PDO("mysql:host=".DBHOST." dbname=".DBNAME."", DBUSER, DBPASS) Initiate a new PDO object called $MYDB and pass it the proper information to make Let's try to connect to the database first. Set up database connection constants, so they cannot be changed.ĭefine('DBHOST','127.0.0.1') //Change this to the ip address of your databaseĭefine('DBNAME','test') // Change this to the database name you are trying to connect to.ĭefine('DBUSER','databaseuser') // Insure this user is not the root user!!!!ĭefine('DBPASS','databasepassword') // Insure this is not the root password!!!!

* If you would like to learn more about PDO,

* Modern method of connecting to a MySQL database and keeping it simple. Try setting localhost:port for dbdefaulthostname,so. Please give the following a try, I have developed and tested it locally, functionality within has been documented to help you understand what is going on in every step. Do verify your username and password, cuz it gives the same error when credentials doesnt.
