![]() |
php/mysql question
i try connect to a mysql database using the function mysql_connect("localhost","username","userpass") but i get this error: Access denied for user: 'root@localhost' (Using password: NO)
why the php is trying to connect with the user "root" and without password since username is other than root and i specify a password (for username) ? |
No idea, this works for me.
$link = mysql_connect("localhost", "root", "password") or die("w00t w00t, error error"); mysql_select_db("database", $link) or die("can't open db"); |
try putting the real mysql ip in the localhost space
|
Quote:
|
not familiar with PHP myself but it looks to me like your not passing the name of the database. Shouldn't you be connecting to a particular db?
|
Quote:
mysql_select_db($dbname) will come after mysql_connect() function... but why i'm geting that mysql error? why is trying to connect as root when i specify a username? :mad: |
try assigning the user and password to a variable and putting the string in place
$host = "127.0.0.1:4321"; $user = blah; $pass = blahblah; mysql_connect($host, $user, $pass) ; |
wrong password or dbname.
|
your file is not in the proper format :)
convert it to proper ascii format with proper line feeds |
Code:
$link = @mysql_connect("$DB_HOST", "$DB_USER", "$DB_PASS"); |
the quotes shouldn't be needed.
|
mysql_connect("localhost","username","userpass") but i get this error: Access denied for user: 'root@localhost' (Using password: NO)
THAT WILL NOT WORK try replacing it with this. $_SESSION['dbhost'] = "localhost"; // $_SESSION['dbusr'] = "xxxxx"; // $_SESSION['dbpwd'] = "xxxxx"; // $_SESSION['dbdb'] = "xxxxx"; // $_SESSION['password'] = "xxxxx"; // If that doesnt work contact me on icq i have another form also |
This one works the best for me i just found it
// MySQL configuration $CONFIG['dbserver'] = 'localhost'; // Your database server $CONFIG['dbuser'] = 'xxxxxx'; // Your mysql username $CONFIG['dbpass'] = 'xxxxxx'; // Your mysql password $CONFIG['dbname'] = 'xxxxxx'; // Your mysql database name |
the fuck are you storing db parameters in the session for?
jesus people, learn how to code. your last example will work, if he uses mysql_connect and mysql_select_db with the appropriate parameters. it won't just work like magic otherwise. of course, unless there's some database abstraction library or related script being loaded that reads those variables like that (highly unlikely with that setup.) |
1. User/PWD not set up in MySQL.
2. Mistyped user name. 3. Mistyped password. No other reason you would get an "Access denied" message. |
there in the session for the script thats being used by that coder, that wasnt one of my codes thats why i posted the second one for him .
|
All times are GMT -7. The time now is 04:57 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123