Jump to content

Problems connecting to MySQL DB using PHP


Maverick Meerkat

Recommended Posts

I created a database called hathix_cabra and created a user (we'll call them hathix_user) with the password,say, 'pass123'. I wrote the following PHP code to try to connect to the database:

 

$dbc = mysqli_connect('cabra.hathix.com','hathix_user','pass123','hathix_cabra') or die('Error connecting to MySQL server.');

 

Sure enough, I get an error about 'access denied' (or sometimes just the generic error message.) I've given the user all privileges, but when I try to FLUSH PRIVILEGES in phpMyAdmin I get an 'access denied' message.

 

I get this specific error message:

[28000] [1045] Access denied for user 'hathix_cabra'@'xxx.xxx.xxx.xxx' (using password: YES)

Sometimes it's 1044 instead of 1045.

 

Am I using the wrong values, or is something else the matter?

Link to comment
Share on other sites

Your doing everything right, except the host (cabra.hathix.com) should be either:

- 'localhost' if you're connecting locally.

- 'stevie.heliohost.org' if you're connecting remotely.

 

If you're connecting remotely you need to enable Remote SQL in cPanel.

 

Moving to 'Questions'. ;)

Link to comment
Share on other sites

I tried 'localhost' as the host in my PHP script, but that didn't work (I got the generic 'error connecting to database' message.) I tried entering 'stevie.heliohost.org' as a remote access host but it didn't show up, and when I tried 'stevie.heliohost.org' as the host in the script that didn't work either (same generic message.)

 

Did I enable the remote SQL wrong or something?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...