mysql connectivity problem
I connect php application to mysql from two different files from one file it
is connecting and from other file it gives me following error message.
Connection Failed because: Access denied for user 'ODBC'@'localhost' (using password: NO)
even i am using same connection string in both files but still problem exist!!
like in this way
$dbh=mysql_connect ('localhost','newuser','mypass');
PHP Code:
$dbh=mysql_connect ('localhost','newuser','mypass');
mysql_select_db ("twmweb");
$result=mysql_query("select * from inventory");
$EOF=mysql_num_rows($result);
above php code working
but following sample function gives above error
PHP Code:
function connect()
{
global $db_name;
$connection = mysql_connect ('localhost','newuser','mypass');
or die("Connection Failed because: " . mysql_error() );
$db = mysql_select_db("twmweb" , $connection) or die("Invalid database name " );
return $connection;
}
i required help as soon as possible
Re: mysql connectivity problem
PHP Code:
$connection = mysql_connect ('localhost','newuser','mypass');
or die("Connection Failed because: " . mysql_error() );
I may be wrong but pretty sure thats not right, it should be...
PHP Code:
$connection = mysql_connect ('localhost','newuser','mypass') or die("Connection Failed because: " . mysql_error() );
Re: mysql connectivity problem
@pino: you are correct.
You need to change the line that pino said. and you error message is saying that you are using the username "ODBC" and you are not using a password.
Re: mysql connectivity problem
You're getting the error message because of the extra semicolon. You're calling mysql_error even when the connection succeeds, which means it spits out the last error message generated.