How do I connect to a MySQL Database with PHP?

Avatar
  • Answered
I've used PHP with MYSQL previously on inMotion with no troubles. However, with a new account I cannot seem to run a simple PHP script that outputs some sample MySQL data. I am included to think there is something wrong with my account because I followed your example on this page ( https://www.inmotionhosting.com/support/website/database-connections/connecting-to-a-database-using-php ) exactly but it fails on line #16 when setting the connection. I can send you my code if you like. The url where I am simply trying to set up the simple PHP page is here: http://mulnixart.com/dbtest2.php
Thanks,

Phil Threadgould
Account Name = XXXXXXX
Avatar
johnpaulb-imhs1
Hello thread7, Thank you for letting us know you were able to get it working. For anyone else who may find this post, here is a link to our guide on How to create a MySQL Database. After it is created, you can create and attach a user to the database in cPanel. Then, you will be able to connect to it using PHP. If you have any further questions, feel free to post them below. Thank you, -John-Paul