Any of my pages trying to connect to the database use this... First two lines on the page (after open php tag)
include.php
Right now on each page that uses this I get this error returned:
Error Occured: 1045 Access denied for user 'root'@'localhost' (using password: NO)
As you can see My first Connect_To_Test_DB is for when I am testing on ym local machine and root with no password is how I access it. When its on the server (like now) I use the second function. It looks like its trying to connect with the first function, but dying in the second function. Does anyone have any ideas? The server and initial password should be right because its not dying there. Its not dying until the actual db selection, whihc I have copied and pasted the db name. Thanks in advance.
Code:
include_once('include.php');
connect_to_db();
include.php
Code:
function connect_to_test_db(){
$conn = mysql_connect(localhost, 'root', '');
if(!conn){
die('Could Not connect: '.mysql_error());
}
mysql_select_db("news");
}
function connect_to_db(){
$conn = mysql_connect(Server, 'Username', 'p@55w0rd'); //not my real password
if(!conn){
die('Could Not connect: '.mysql_error());
}
if(!mysql_select_db("news"))
die('Error Occured: '.mysql_errno()." ".mysql_error());
}
Right now on each page that uses this I get this error returned:
Error Occured: 1045 Access denied for user 'root'@'localhost' (using password: NO)
As you can see My first Connect_To_Test_DB is for when I am testing on ym local machine and root with no password is how I access it. When its on the server (like now) I use the second function. It looks like its trying to connect with the first function, but dying in the second function. Does anyone have any ideas? The server and initial password should be right because its not dying there. Its not dying until the actual db selection, whihc I have copied and pasted the db name. Thanks in advance.