Jump to content


Photo

Connection to database problem


  • Please log in to reply
2 replies to this topic

#1 charles8555

charles8555
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 November 2005 - 09:03 AM

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

#2 Mattyspatty

Mattyspatty
  • Members
  • PipPipPip
  • Advanced Member
  • 76 posts
  • LocationEngland :D

Posted 02 November 2005 - 10:14 AM

double check your using the correct password, i am assuming ur doing it on your local machine so that souldnt be much of a problem, also can u login to the database with those user/pass if u can then make sure the inc file is correctly included
ok, so my PHP is a bit rusty... my replies are 90% ok.
the other 10% either have syntax errors or are the "hard solution"
http://www.php.net  http://www.google.com - Are your friends!

I have a C++ problem with 'keybd_event' in certain applications. if you can help me PM me! :P
Needs motivation to create another quick cash website. I need a new TV

#3 charles8555

charles8555
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 November 2005 - 05:43 PM

hi..thanks for replying my post..yea i think i solve the problem..thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users