|
-
Jul 26th, 2007, 02:27 AM
#1
Thread Starter
Fanatic Member
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
-
Jul 26th, 2007, 09:02 AM
#2
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() );
-
Jul 26th, 2007, 01:16 PM
#3
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.
My usual boring signature: Something
-
Jul 26th, 2007, 08:38 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|