PDA

View Full Version : Testing MySql


radmaneshp
4-6-02, 07:49 PM
I'm trying to test a connection to a database on my computer. I downloaded the MySql server and set it up successfully. I then tested a connection to it using MyCC (Control Center) and it connected successfully (to localhost). So now I'm trying to connect from my website (to localhost) just to test MsSql out from PowWeb, but I keep getting an Access denied error. Here's the code.

#!/usr/local/bin/php

<HTML>
<HEAD><TITLE>PHP Test 2</TITLE></HEAD>
<BODY><CENTER>
<? echo(mysql_connect("localhost:3306","user","")); ?>
</CENTER></BODY>
</HTML>


and here's the error

Warning: Access denied for user: 'user@localhost' (Using password: NO) in /www/r/radmaneshp/cgi-bin/test2.php on line 5

Warning: MySQL Connection Failed: Access denied for user: 'user@localhost' (Using password: NO) in /www/r/radmaneshp/cgi-bin/test2.php on line 5

Does anyone know why this is happening? And yes, I did have my server running when I tryed it because it worked using MyCC. Thanks.

sophiespo
4-6-02, 08:50 PM
you need to put in your username and password (shown in bold below)

#!/usr/local/bin/php

<HTML>
<HEAD><TITLE>PHP Test 2</TITLE></HEAD>
<BODY><CENTER>
<? echo(mysql_connect("localhost:3306","user","pass")); ?>
</CENTER></BODY>
</HTML>

sophie

radmaneshp
4-6-02, 08:57 PM
My username and password are there. I have it set up as "user" with no password (on the server). It worked with the other program.

user@localhost, and no password required

sophiespo
4-6-02, 09:02 PM
is this code running on your website on your machine or on powweb servers? From the look of your errors, youve got this code on your website on powweb. localhost, then, will refer to the server your website is on (e.g. server.powweb.com) and not YOUR machine..

sophie

radmaneshp
4-6-02, 09:05 PM
Ah, I see. So if I want to test it out I got to replace localhost with the current IP address. I'm using AOL so it always changes, but I can use the current one. You think that might work?

Starr
4-6-02, 09:06 PM
Replace "localhost" with the hostname of the web server your mySQL database is on, or the domain name of the account that has the mySQL database set up for it.

I am assuming that you have ordered and setup your mySQL database via Ops..

radmaneshp
4-6-02, 09:08 PM
Not yet. Right now I have the server running on my computer at home, just to test it out. I'm gonna try your idea and switch localhost to my IP address. I'll be right back.

sophiespo
4-6-02, 09:09 PM
Starr he is trying to test out MySql that he has installed on HIS computer, not a MySql database ordered through PowWeb. I believe he is allowed to do this...

Anyway. I would assume that you would use your current IP address. Ive never set up a server before and done this, so I dont know for sure. Youll find out soon enough if it doesnt work, anyway.

sophie

radmaneshp
4-6-02, 09:14 PM
It worked, thanks a bunch. I assumed that localhost would mean your computer. I didn't know it meant the server you're on. It connects fine. I am gonna purchase the MySql from PowWeb, I just wanted to make sure I could use it first. Thanks for your help.

Peter :-)

sophiespo
4-6-02, 09:18 PM
localhost always refers to the particular machine the code is being run from :)

glad you got it going.

sophie