When connecting to mysql database using php, where do I acquire my "username" &

  • Thread starter Thread starter Yiaggi
  • Start date Start date
Y

Yiaggi

Guest
"password" ? Hi guys,

I am connecting a simple guest book with a mysql database to my website using php and having a few problems connecting.

I know that you need to use this code (username & p/w have been changed for purposes of this post):

<?php
$host="localhost";
$username="myusername";
$password="mypassword";
$db_name="mrcagb";
$tbl_name="guestbook";

mysql_connect("$host", "$username", "$password")or die("cannot connect server ");

mysql_select_db("$db_name")or die("cannot select DB ". mysql_error());

My problem is that whenever I try to add to my guestbook I get a message saying:

cannot select DB Access denied for user 'myusername' to database 'mrcagb'.

--------------------------------------------

I'm assuming that this has something to do with the username I am using? I got that username & password from the people who host my website. I was required to log onto a 'control panel' on their website and set access to mysql.

* Am I using the wrong details to log in?

* Should I have somehow set these details in my mysql database to allow access when I try to do so with php?

I have posted numerous questions and, in doing so, have managed to find out that my coding seems to be fine. It is just this last thing!

Please please help if you can! Will give you lots of little star things if you give me a correct answer! :)

Ta in advance.
 
Back
Top