Cannot Connect to DB using PHP

Category: Databases

kbaxter
Asked:
2012-07-14 4:33 pm EST

Hits: 561
I have followed the sample in the tutorial series - http://www.inmotionhosting.com/support/edu/website-design/using-php-and-mysql

and found each tutorial very helpful, thank you!

I was able to create the db and table and have inserted the html code and php into the script module (using the premium web builder wizard). I continue to receive an error in connecting to the DB and do not know how to determine what the error is. I have modified the below statement to input the correct userid and password for the database.

Could the error be that the localhost is not finding the database? Since the php code was not placed in the File Manager section that the sample states and the comments state "because the database lives on the same physical server as our php code, we are connecting to localhost". Is this where the problem lies if I have inserted the html and all sample code into the script module in the premium builder module?

$con = mysql_connect("localhost","userid","mypassword");

Thanks,
Kathe

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

Scott
Staff
20,166 Points
2012-07-16 10:24 am EST
Hello Kathe,

Without seeing the entire code, I would not be able to answer whether that line is incorrect, but as a general code statement it appears to be correct. 'Localhost' is definitely the setting you want to use on the server.

I was unable to find a page on your site that seemed to be having an issue. I may need a bit more information so I can take a look at the actual code and test it. You can send the specific information to docs@inmotionhosting.com Be sure to validate your account with either the last 4 digits of the credit card on file, or the current Account Management Panel (AMP) password. As we do not actively monitor that address, be sure to leave a comment below so we know the information was sent. I would also need the builder password to access that area to get the code itself.

Best Regards,
Scott M

You must login before you can post a comment about this answer.

Like this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!