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

From: W i l l (willis3140_at_yahoo.com)
Date: 09/30/04


Date: 30 Sep 2004 11:01:29 -0700

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!



Relevant Pages

  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)
  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)
  • Re: com_dotnet
    ... And if MySQL isn't installed, the DLL won't load and phpinfowill show MySQL support isn't enabled. ... The MySQL interface is NOT compiled into PHP on the distributed Windows binaries - or you'd never be able to run PHP unless you had MySQL installed. ... *SOME* extensions are protocols, some are functional resources, and some are just type libraries. ... If you're going to compile the extension into PHP itself, the libraries must be available at compile time, and when you run PHP, or PHP won't load. ...
    (comp.lang.php)
  • Re Re: PHP 5.2.4 <= various mysql functions safemode & open_basedir bypass
    ... > various mysql functions safemode & open_basedir bypass ... PHP is currently very used because it's easy to use. ... Apache has directory restrictions. ... # if the mysql user has perms, ...
    (Bugtraq)
  • Re: question about playlist
    ... I have a dynamic playlist, playlist_1.asx, created by a php script from a ... the mysql table contain information about: ... movie near to the playing movie, and when change the movie, contextually ... Change the information in the *database* table, or in the HTML table? ...
    (microsoft.public.windowsmedia.server)