Forum Moderators: coopster

Message Too Old, No Replies

mysql connection error.

         

afridy

10:11 am on Apr 15, 2006 (gmt 0)

10+ Year Member



Hi.

i am in my early days on intergrating MY Sql with PHP.
My windows 2000 server has bought PHP and MYsql installed.

When i attempt to connect to the mysql server using the forllowing PHP code
the below error message appears.

"Fatal error: Call to undefined function mysql_connect() in E:\Web_Server\php\con_mysql.php on line 2"

my php code is as follows.

[php]
<?php
$link = mysql_connect('MYSERVER', 'admin', '123456');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
[/php]

What could be the problem?

Habtom

10:19 am on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It seems to me that your APACHE is not running, but your code is fine.

Habtom

Birdman

12:27 pm on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It sounds to me like you installed PHP without MySQL support. Run this simple script to find out:

<?php
phpinfo();
?>

At the top, in the Configure Command section, you will find either:

--with-mysql

or

--without-mysql

If you have --without, then you need to reinstall PHP and make sure to add MySQL.

Habtom

1:10 pm on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Birdman - I think that is it.

If you are mysql is installed you might try editing php.ini to enable mysql support. I just looked around to come up with this.

Habtom

afridy

3:01 pm on Apr 15, 2006 (gmt 0)

10+ Year Member



Thank you for your all. i ll now check with my win2k.

my webserver is not apache. it is win2k iis. it is in an itranet. but my code i shown in the first post is just working fine in my webserver registred in godaddy.

problem really with win2k iis in my local intranet. i ll come back in a moment.

afridy

3:52 pm on Apr 15, 2006 (gmt 0)

10+ Year Member



Hi. this is the php info results
* i have attached the first table data

PHP Version 5.0.4

System Windows NT MYSERVER 5.0 build 2195
Build Date Mar 31 2005 02:44:34
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
Server API CGI/FastCGI
Virtual Directory Support enabled
Configuration File (php.ini) Path E:\WINNT\php.ini
PHP API 20031224
PHP Extension 20041030
Zend Extension 220040412
Debug Build no
Thread Safety enabled
IPv6 Support enabled
Registered PHP Streams php, file, http, ftp, compress.zlib
Registered Stream Socket Transports tcp, udp

This is the my.ini file in winmysqladmin.

#This File was made using the WinMySQLAdmin 1.4 Tool
#4/14/2006 8:54:39 PM

#Uncomment or Add only the keys that you know how works.
#Read the MySQL Manual for instructions

[mysqld]
basedir=C:/mysql
#bind-address=128.10.0.1
datadir=C:/mysql/data
#language=C:/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
#set-variable=key_buffer=16M
[WinMySQLadmin]
Server=C:/mysql/bin/mysqld-nt.exe
user=admin
password=123456

Birdman

3:58 pm on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I haven't used Windows in a long time, but I still think you need to re-install PHP and make sure to enable mysql.

afridy

4:20 pm on Apr 15, 2006 (gmt 0)

10+ Year Member



Birdman.

actually what you sad is not there :(

--with-mysql

or

--without-mysql

Birdman

4:44 pm on Apr 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably because it is only showing the --with options. On Nix boxes it shows everything. Either way, you do not have MySQL support. Otherwise, mysql_connect() would be recognized.

afridy

4:48 pm on Apr 15, 2006 (gmt 0)

10+ Year Member



Thanks birdman.

yah. now one thing is clear. ok . ill configure again php and sql bought and come with the results soon.