473,320 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

mysql_connect error

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
7 5389
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
-----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
> > 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
> 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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BT | last post by:
Hi .. a newbie question. I get the following error: Fatal error: Call to undefined function: mysql_connect() in /var/www/html/index.php on line 3. I have the following RPMS installed on RH7.2...
7
by: Frogman | last post by:
Hi, I am new to php and I'm testing php connectivity to mysql. I created a php script using the php.net sample. The script uses the mysql_connect method and when I execute it I get the error: ...
2
by: Frobinrobin | last post by:
I am running Win2k3 Server and when I try to use the mysql_connect function I am getting an error: Fatal error: Call to undefined function mysql_connect() in...
2
by: Sugapablo | last post by:
I have a small test script connecting to a MySQL database. It seems to work, unless I try to use the resource link identifier returned by mysql_connect(); This works and returns all the rows in...
1
by: ezmiller | last post by:
Hi, I am very new to php, and I am trying to use it to access a mysql database. But I'm trying to use mysql_connect but the browser returns the following error sayin that the mysql_connect...
6
by: GD | last post by:
Hi All, I've got MySQL 5.0.21 running on Windows Server 2003, and php running on Apache on a Linux box (Fedora Core 4). Previously when the pages were running on an IIS server the connection...
1
by: hugo | last post by:
Hello people, There is a problem is that mysql_connect() somehow caches last sessions IP and is not using the one which you put into host place. Has anyone made mysql_connect() from php to...
7
by: criveraf | last post by:
Hi there, I wasn't sure where to put this question, since it deals with both PHP and MySQL. I apologize if this is not the correct forum for this. I am working with a simple PHP application...
2
by: Ralf Seliger | last post by:
Hi, I hope someone here has a clue as to what is going on since I am completely baffled by the following: I'm working with a PHP/MySQL-web application called Moodle. When this application is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.