Jump to content

I can't connect to mysql database


Recommended Posts

Hi

 

I am trying to connect to a mysql database through phpmyadmin. I have followed the steps in this video

and still no luck.

 

 

 

 

This is my code;

 

<?phpDEFINE ('DB_USER' , 'jazza' );DEFINE ('DB_PSWD' , 'jarrod');DEFINE ('DB_HOST' , 'localhost:8889');DEFINE ('DB_NAME' , 'ask');$dbcon = mysqli_connect(DB_HOST, DB_PSWD, DB_USER, DB_NAME);if (!$dbcon) { die('error connecting to database');}echo 'you have connected succesfully' ;?>

 

 

In the database 'question' I have created a table called 'ask.' I have created a user 'jazza' and password 'jarrod'. On the top of the page it says 'server:8889'.

When I try to test it on my server through dreamweaver, it says 'error connecting to database'.

 

 

I can't figure out where I went wrong. Can anyone help me out?

 

 

 

Thanks

Edited by Jazza
Link to post
Share on other sites

What you need for DB_NAME is not 'ask'. That is the name of the table. You need to use the database name, which you said was 'question'.

 

Also, you should never post your username/password publically. I'd recommend changing them.

Edited by Ixzion
Link to post
Share on other sites

What you need for DB_NAME is not 'ask'. That is the name of the table. You need to use the database name, which you said was 'question'.

 

Also, you should never post your username/password publically. I'd recommend changing them.

Still no luck connecting.

Link to post
Share on other sites

Just a guess, but you have them out of order. You have...

$dbcon = mysqli_connect(DB_HOST, DB_PSWD, DB_USER, DB_NAME);
...and it should be...
$dbcon = mysqli_connect(DB_HOST , DB_USER , DB_PSWD , DB_NAME);
I'm pretty sure that it matters what order you put them in.....Hope it helps.
Link to post
Share on other sites

Remove the port number. Unless you changed MySQL to listen on port 8889, that is not the correct port. Leave the port off and see if it connects on the default port (3306). If not, then you need to figure out which port MySQL is listening on. It will not be the same port as HTTP.

Link to post
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.

Loading...
×
×
  • Create New...