Jump to content

Connection to database problem


charles8555

Recommended Posts

hello..everyone..i got the very weird problem with my connection to database..currently i doing some program with php and mysql, and i use include 'db.inc'; file for every php file where i want to query to the database..ok here is my problem...because of the covenience i use statment like

i declare the variable as

$hostName = "localhost";

$username = "root";

$password = "123";

$databaseName = "testing";

at my db.inc file

$connection = mysql_connect($hostName, $username, $password);
 mysql_select_db($databaseName, $connection);

 

but when i try to connect it give me an error message like this..

Error 1045 : Access denied for user 'root'@'localhost' (using password: YES)

 

but i when i replace the above statment like below

    if(!($connection = @ mysql_connect("localhost", "root", "123")))
      die("Cannot connect2");

    if(!(mysql_select_db("testing", $connection)))
      showerror();

 

it is same thing isn't it...but i jus get the erro when i replace the above statement..

can anyone help me to figure it out..thanks..for viewing this thread..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.