473,563 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5405
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*********@kde talk.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEG0zx3jc Q2mg3Pc8RAj8UAJ 9EqD+RZp7Fa2n8u diS/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","roo t","password ") this not
working but when I use mysql_connect(" 127.0.0.1","roo t","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","roo t","password ") this not
working but when I use mysql_connect(" 127.0.0.1","roo t","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\SYST EM32\DRIVERS\ET C 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******** *************@u 72g2000cwu.goog legroups.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
9969
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 MySQL-client-4.0.14-0 I would really appreciate it. MySQL-shared-4.0.14-0 MySQL-server-4.0.14-0 MySQL-devel-4.0.14-0
7
2661
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: Fatal error: Call to undefined function: mysql_connect() in /var/www/html/testPHP/testMysql.php on line 7 I have mysqld ver 4.0.20 and php 4.2.2...
2
1997
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 C:\Inetpub\wwwroot\programs\index.php on line 8 Now, I def know I've configured my php.ini correctly (its literally the same as my XP machine) and I know that mysql works fine with...
2
2827
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 the table: <?php include("../config.php"); $dbi = mysql_connect($dbhost,$dbuname,$dbpass);
1
5630
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 function is undefined. Why? Can anyone help? Fatal error: Call to undefined function mysql_connect() in...
6
3354
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 was succesful, now I get: Can't connect to MySQL server on 'SERVER' (13)
1
4353
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 multiple SQL servers so that script tries to connect to resolved IPs until it finds one that works? I have set up DNS so that on request...
7
2839
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 using MySQL at the data layer. This is on a Windows XP machine, using IIS 6.0, MySQL 5.0, PHP 5. The problem I am having is that a call to...
2
2015
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 started from a web browser, one of the first things to happen is a call to mysql_connect which succeds without any problems. One component of...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.