GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   php/mysql question (https://gfy.com/showthread.php?t=446334)

alex79 03-20-2005 03:05 PM

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) ?

Jakke PNG 03-20-2005 03:07 PM

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");

Doc911 03-20-2005 03:16 PM

try putting the real mysql ip in the localhost space

alex79 03-20-2005 03:44 PM

Quote:

Originally Posted by Doc911
try putting the real mysql ip in the localhost space

still not working :(

blazin 03-20-2005 03:49 PM

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?

alex79 03-20-2005 03:57 PM

Quote:

Originally Posted by blazin
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?


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:

Doc911 03-20-2005 04:46 PM

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) ;

grumpy 03-20-2005 06:44 PM

wrong password or dbname.

teksonline 03-20-2005 06:50 PM

your file is not in the proper format :)

convert it to proper ascii format with proper line feeds

Dynamix 03-20-2005 08:24 PM

Code:

$link = @mysql_connect("$DB_HOST", "$DB_USER", "$DB_PASS");
$db_selected = mysql_select_db($DB_DB, $link);

always works for me. set the variables above the connect line and you're good to go. check with your server admin, perhaps your databases aren't properly setup. It has nothing to do with the host IP as you're at least getting a reply.

mike503 03-20-2005 08:26 PM

the quotes shouldn't be needed.

Pete-KT 03-20-2005 08:37 PM

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

Pete-KT 03-20-2005 08:40 PM

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

mike503 03-20-2005 08:44 PM

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

broke 03-20-2005 08:47 PM

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.

Pete-KT 03-20-2005 08:48 PM

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