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:
<?php
// 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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>mysql page</title>
</head>
<body>
<table>
<tr>
<th>Id</th>
<th>Site</th>
</tr>
<?php while ($array = mysql_fetch_row($result)) : ?>
<tr>
<td><?php echo $array[0] ?></td>
<td><?php echo $array[1] ?></td>
</tr>
<?php endwhile; ?>
</table>
</body>
</html>
--------------------------
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)
--snip--
MySQL is not the problem:
--snip--
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)
mysql>
-----------------------------------
TIA!