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

mysql_connect() fails - PHP, Apache, MySQL on WinXP

P: n/a
I have Apache 2 parsing and serving PHP files just fine on my winXP
box, however, when I try to add some mysql database functionality I
get a warning that looks like this:

Fatal error: Call to undefined function mysql_connect() in
D:\SITES\mysql.php on line 3

I am able to connect to mysql via the terminal just fine. Due to the
error "undefined function" I wonder if I set PHP up wrong or
something. Any ideas?

Here is the code:

// basic install of MySQL 4.0.20a-nt
$mysql = mysql_connect("localhost","root","mysql");

$query = "select id, site from crypt";

$result = mysql_db_query("test", $query);

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html;
<title>mysql page</title>
<?php while ($array = mysql_fetch_row($result)) : ?>
<td><?php echo $array[0] ?></td>
<td><?php echo $array[1] ?></td>
<?php endwhile; ?>


And here is some other info that might be useful to you:

Z:\>c:\php\php -v
PHP 5.0.0 (cli) (built: Jul 13 2004 21:39:58)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.0, Copyright (c) 1998-2004 Zend Technologies

Z:\>mysql -V
mysql Ver 12.22 Distrib 4.0.20a, for Win95/Win98 (i32)

MySQL is not the problem:
Z:\>mysql -uroot -pmysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 4.0.20a-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use test;
Database changed
mysql> select id, site from crypt;
| id | site |
| 1 | foo |
| 2 | hotmail |
| 3 | hotmail |
| 4 | hotmail |
4 rows in set (0.00 sec)



Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.