By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,779 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,779 IT Pros & Developers. It's quick & easy.

mysql_connect problem ...

P: n/a
this is the code:

$user = "user";
$pass = "";
$connect = mysql_connect('localhost',$user,$pass);
or die('could not connect: '. mysql_error());

mysql_close($connect);

i'm a beginer, and i just want to see if i could connect to server.
on pypmyadmin i set the following for the user@localhost:

password: No
global privileges: all privileges
grant: yes ...

and ofcourse i get the warning: mysql_connect()function.mysql-connect]:
Access denied for user 'user'@'localhost' error on the connect string line.

it has everything, and why doesnt connect string he let me in.
please help ...
Jun 18 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On Sun, 18 Jun 2006 08:11:31 +0200 dude wrote:
this is the code:

$user = "user";
$pass = "";
$connect = mysql_connect('localhost',$user,$pass);
or die('could not connect: '. mysql_error());


Try "127.0.0.1" instead of "localhost". This usually does the trick. Ow and
get a real name, dude :D

Best regards,
Jan Thomä
Jun 18 '06 #2

P: n/a
dude wrote:
this is the code:

$user = "user";
$pass = "";
$connect = mysql_connect('localhost',$user,$pass);
or die('could not connect: '. mysql_error());

mysql_close($connect);

i'm a beginer, and i just want to see if i could connect to server.
on pypmyadmin i set the following for the user@localhost:

password: No
global privileges: all privileges
grant: yes ...

and ofcourse i get the warning: mysql_connect()function.mysql-connect]:
Access denied for user 'user'@'localhost' error on the connect string line.

it has everything, and why doesnt connect string he let me in.
please help ...


If you use 'localhost' mysql will often try to connect via a named-pipe
which involves having the named pipe set up and the permissions correct.

If you use 127.0.0.1 (i.e. the TCP/IP loopback to localhost) mysql will
use the TCP/IP stack instead.

Since 127.0.0.1 is well known to the TCP/IP driver, it is all resolved
in memory so there is no real performance penalty using it vis-a-vis
named pipes.

-david-

Jun 18 '06 #3

P: n/a
> Try "127.0.0.1" instead of "localhost". This usually does the trick. Ow and
get a real name, dude :D

Best regards,
Jan Thomä


hey dude, this doesn't work dude ... what a disaster dude :(
eny more tricks i can try, dude ?
google says allot but nothing that i can use and solve this ...

aha, about the name, i will have to change it, its terrible :D
Jun 18 '06 #4

P: n/a
dude wrote:
Try "127.0.0.1" instead of "localhost". This usually does the trick.
Ow and
get a real name, dude :D
Best regards,
Jan Thomä


hey dude, this doesn't work dude ... what a disaster dude :(
eny more tricks i can try, dude ?
google says allot but nothing that i can use and solve this ...

aha, about the name, i will have to change it, its terrible :D

Can you connect to mysql from the command line?
If not, then you need to work out how to create the account
user@localhost in mysql before trying to connect to it from php.

If this is your problem, take a look at the 'GRANT' section of mysql.

-david-

Jun 18 '06 #5

P: n/a
dude wrote:
this is the code:

$user = "user";
$pass = "";

define('DB_USER','user');
define('DB_PASSWORD','');
define('DB_HOST','localhost');

Works for me, YRMV.
--
TK
http://www.wejuggle2.com/
Still Having a Ball



..

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jun 18 '06 #6

P: n/a
dude schrieb:
Try "127.0.0.1" instead of "localhost". This usually does the trick.
Ow and
get a real name, dude :D
Best regards,
Jan Thomä


hey dude, this doesn't work dude ... what a disaster dude :(
eny more tricks i can try, dude ?
google says allot but nothing that i can use and solve this ...

aha, about the name, i will have to change it, its terrible :D


Have you reloaded the user-tables after adding the user? ( FLUSH
PRIVILEGES ;)

Florian
Jun 18 '06 #7

P: n/a
thank you ALL ... have a nice day ...
Jun 18 '06 #8

P: n/a
Terry wrote:
dude wrote:
this is the code:

$user = "user";
$pass = "";


define('DB_USER','user');
define('DB_PASSWORD','');
define('DB_HOST','localhost');

Works for me, YRMV.


The only difference is he's using variables and you're using constants. Either
will work fine.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 18 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.