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

mysql_connect error

P: n/a
Hi,

I got error when using mysql_connect function in my php script.
If i set the db host to localhost, it give me that error altough all
the user and password that I wrote is true(I can login using that
username/passwd using mysql console), but when I change the db host
into 127.0.0.1 mysql_connect will work.
Beside of that I can't make my php script to do I/O operation on
dir/file in the apache /var/www though the permision already own by
apache uid, even if I gave the permision to 777(just for the testing
sake) the I/O operation still wont work.
I really confuse what else to do :'(
I'm using SuSE 10, Apache/2.0.54, and php 4.5 (it's all from standard
rpm that provided by SuSE)

Mar 17 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
av******@gmail.com wrote:
Hi,

I got error when using mysql_connect function in my php script.
If i set the db host to localhost, it give me that error altough all
the user and password that I wrote is true(I can login using that
username/passwd using mysql console), but when I change the db host
into 127.0.0.1 mysql_connect will work. What were you using before?
Beside of that I can't make my php script to do I/O operation on
dir/file in the apache /var/www though the permision already own by
apache uid, even if I gave the permision to 777(just for the testing
sake) the I/O operation still wont work.


What happens for a file somewhere else, like /tmp?

--
Ian Collins.
Mar 17 '06 #2

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

av******@gmail.com wrote:
I got error when using mysql_connect function in my php script.
If i set the db host to localhost, it give me that error altough all
the user and password that I wrote is true(I can login using that
username/passwd using mysql console), but when I change the db host
into 127.0.0.1 mysql_connect will work.


Is there an entry in your /etc/hosts file regarding 'localhost'??

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_*************************@hotmail.com
Jabber:iv*********@jabber.org ; iv*********@kdetalk.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEG0zx3jcQ2mg3Pc8RAj8UAJ9EqD+RZp7Fa2n8udiS/oS59x2OvQCfcZy/
VOA0vJhV/G6FSXNc9LtIZgs=
=RlKw
-----END PGP SIGNATURE-----
Mar 18 '06 #3

P: n/a
> > I got error when using mysql_connect function in my php script.
If i set the db host to localhost, it give me that error altough all
the user and password that I wrote is true(I can login using that
username/passwd using mysql console), but when I change the db host
into 127.0.0.1 mysql_connect will work. What were you using before?

before I use mysql_connect("localhost","root","password") this not
working but when I use mysql_connect("127.0.0.1","root","password")
will work
Beside of that I can't make my php script to do I/O operation on
dir/file in the apache /var/www though the permision already own by
apache uid, even if I gave the permision to 777(just for the testing
sake) the I/O operation still wont work.


What happens for a file somewhere else, like /tmp?

Also will break even in /tmp dir, if I execute it using shell with php
command will work, I think mod php in my apache on SuSE 10 has some
problem which I don't understand

Uung

Mar 19 '06 #4

P: n/a
> Is there an entry in your /etc/hosts file regarding 'localhost'??
Yes there is, also had correct host permision for localhost in mysq
table permision

Mar 19 '06 #5

P: n/a
"av******@gmail.com" wrote:
I got error when using mysql_connect function in my php script.
If i set the db host to localhost, it give me that error altough all
the user and password that I wrote is true(I can login using that
username/passwd using mysql console), but when I change the db host
into 127.0.0.1 mysql_connect will work.

What were you using before?

before I use mysql_connect("localhost","root","password") this not
working but when I use mysql_connect("127.0.0.1","root","password")
will work


Have you checked if 'localhost' resolves?

Bye!
Mar 19 '06 #6

P: n/a
Have you checked if 'localhost' resolves?

I'm not sure I get what you mean, I can ping localhost which point to
127.0.0.1 and can also use localhost if I login with mysql shell in
console.
Guess my apache is acting really wierd

Mar 20 '06 #7

P: n/a
You should have the line
127.0.0.1 localhost
in a file called hosts
in C:\WINDOWS\SYSTEM32\DRIVERS\ETC if you are on XP or in /etc if you are on
*NIX (if I remember correctly), in order for this to resolve correctly.
if you are on Windows and you make this change, you will need to execute
nbtstat -R
afterwards to reload the internal name cache so localhost is recognized.
You shouldn't have any troubles with Apache after that.
in fact, you can give other names to 127.0.0.1 for use with apache virtual
hosts.
127.0.0.1 localhost bob george www.mytestphpsite.com
but if you do this, you won't have access to the real www.mytestphpsite.com
on the internet because it maps to your local box.
this is where batch files and scripts come in handy for swapping
configurations (if need be).

<av******@gmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Have you checked if 'localhost' resolves?

I'm not sure I get what you mean, I can ping localhost which point to
127.0.0.1 and can also use localhost if I login with mysql shell in
console.
Guess my apache is acting really wierd

Mar 27 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.