Fatal error: Call to undefined function mysql_connect()

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Fatal error: Call to undefined function mysql_connect()

Postby Eric Pement » 19. May 2007 19:36

I've just installed XAMPP for Windows, version 1.6.1, using the Installer/Setup program. I installed XAMPP to the default directory of "C:\Program Files\xampp". I have Windows XP Home Edition, SP 2.

The XAMPP Control Panel Application tells me that Apache and MySQL services are both running. I can pull up the sample page on "http://localhost/xampp/", but when I try the demo "CD Collection" I get this error message from PHP:
Code: Select all
   Fatal error: Call to undefined function mysql_connect()
   in C:\Program Files\xampp\htdocs\xampp\cds.php on line 64

Since I know that mysql_connect() is a valid PHP function, I searched the message forums here to see about reported similar problems. Someone mentioned the problem of having multiple "php.ini" files. Using the 4NT utility ffind, I located 3 of them ... installed by default (why??):
Code: Select all
   [c:\program files\xampp]
   [0]> ffind /dc php.ini
   C:\Program Files\xampp\apache\bin\php.ini
   C:\Program Files\xampp\php\php.ini
   C:\Program Files\xampp\php\php4\php.ini

The top 2 files in "~\apache" and "~\php" are identical, but the one in "~\php\php4" is quite different from the others. When I run phpinfo() from within the localhost demo pages, it reports that PHP is using this config file: "C:\Program Files\xampp\apache\bin\php.ini" and PHP v5.2.1.

I searched the output of phpinfo() and the string "mysql" does not occur in it anywhere (case-insensitive search, btw). The string "sql" occurs only once, here:
Code: Select all
   Directive       Local value  Master value
   ...
   sql.safe_mode     Off       Off

So, what's wrong? It appears that PHP is not set up with support for MySQL, which seems strange. What other diagnostics can I do? Any help would be truly appreciated.

Kind regards,

Eric Pement
Eric Pement
 
Posts: 25
Joined: 19. May 2007 18:35

Postby Wiedmann » 19. May 2007 19:51

it reports that PHP is using this config file: "C:\Program Files\xampp\apache\bin\php.ini"

Is the MySQL extension enabled in this file?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Eric Pement » 20. May 2007 06:38

Wiedmann wrote:
it reports that PHP is using this config file: "C:\Program Files\xampp\apache\bin\php.ini"

Is the MySQL extension enabled in this file?

Yes, the MySQL extension is enabled in this file.

This did not solve the problem, but inspecting the PHP.INI file with a text editor gave me the solution. The file "PHP.INI" contains several directives for directories; each directive contains the string "_dir":
Code: Select all
   safe_mode_include_dir =
   safe_mode_exec_dir =
   user_dir =
   extension_dir = "\xampp\php\ext"
   upload_tmp_dir = "\xampp\tmp"
   soap.wsdl_cache_dir = "\xampp\tmp"
   ;eaccelerator.cache_dir = "\xampp\tmp"

However, the Windows Installer program by default installs XAMPP into "c:\Program Files\xampp", and it does not update the PHP.INI files to show this directory path!

I manually changed all the non-empty paths to "\Program Files\xampp\[etc.]" and now MySQL is running and everything works as it should! Thank you for pointing me in the right direction.

As a new user of XAMPP, I do not know whether I should insert values for "user_dir" or "safe_mode_include_dir", so I have left them blank. Perhaps you can tell me how safe_mode should be used with XAMPP?
Eric Pement - pemente [at] northpark [dot] edu
Eric Pement
 
Posts: 25
Joined: 19. May 2007 18:35

Postby Wiedmann » 20. May 2007 09:53

the Windows Installer ... does not update the PHP.INI files to show this directory path!

Did the program change the file "httpd.conf" (and the other *.conf files) correctly?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Eric Pement » 22. May 2007 22:39

Wiedmann wrote:
the Windows Installer ... does not update the PHP.INI files to show this directory path!

Did the program change the file "httpd.conf" (and the other *.conf files) correctly?

It appears that it did, accurately putting "c:/Program Files/xampp" where needed (note the forward slashes). However, I did notice this in the file "c:\Program Files\xampp\apache\conf\httpd.conf" :
Code: Select all
# Apache parses all CGI scripts for the shebang line by default.
# This comment line, the first line of the script, consists of the symbols
# pound (#) and exclamation (!) followed by the path of the program that
# can execute this specific script.  For a perl script, with perl.exe in
# the C:\Program Files\Perl directory, the shebang line should be:

   #!c:/program files/perl/perl

# Note you _must_not_ indent the actual shebang line, and it must be the
# first line of the file.  ...

Any Perl user would recognize that this is not accurate because the "bin" directory is missing. It should be "#!c:/program files/perl/bin/perl". Except that XAMPP itself installs perl here: "c:/program files/xampp/perl/bin/perl.exe"

Is there anything to be gained by using the version of Perl in the XAMPP folder as opposed to (say) the version by ActiveState (c:/Perl/bin/perl.exe) or by Cygwin (c:/cygwin/bin/perl.exe) ? I have all 3 installed, so what do you recommend? Thanks in advance.
Eric Pement - pemente [at] northpark [dot] edu
Eric Pement
 
Posts: 25
Joined: 19. May 2007 18:35


Return to XAMPP for Windows

Who is online

Users browsing this forum: hthnightwolf and 67 guests