Jump to content

Php & Mysql Fatal Error:


chibineku
 Share

Recommended Posts

I have installed Apache, PHP and MySQL, and my configuration of Apache and PHP is fine, and MySQL works from the command line, but when I try to connect through PHP, I get the above error, whether I use mysql_connect() or mysqli_connect(). I have checked out the official site and there are some fixes, which I tried, including uncommenting these extensions in the php.ini file, copying various .dll files into the windows, windows/system and windows/system32 folders, and nothing seems to fix it. Anyone have any suggestions? I'm using Vista, PHP 5.2, MySQL 5, and Apache 2.2

Link to comment
Share on other sites

The problem is that the mysql extension is not loaded. Create a phpinfo page and go to it:<?php phpinfo(); ?>It will tell you the path that it's using for php.ini, the extension dir path, etc. Make sure you're editing the correct php.ini and uncomment the extension line, and make sure the php_mysql.dll file is in the extension directory and that the web server is able to read that directory. Make sure to restart the web server after changing php.ini.

Link to comment
Share on other sites

The problem is that the mysql extension is not loaded. Create a phpinfo page and go to it:<?php phpinfo(); ?>It will tell you the path that it's using for php.ini, the extension dir path, etc. Make sure you're editing the correct php.ini and uncomment the extension line, and make sure the php_mysql.dll file is in the extension directory and that the web server is able to read that directory. Make sure to restart the web server after changing php.ini.
Can I show you a few of the pertinent bits?In php.ini, I have this:
; Directory in which the loadable extensions (modules) reside.extension_dir = "./ext"

I originally had "./" and that didn't work, so I thought I'd try the ext directory.Later:

;extension=php_bz2.dll;extension=php_curl.dll;extension=php_dba.dll;extension=php_dbase.dll;extension=php_exif.dll;extension=php_fdf.dll;extension=php_gd2.dll;extension=php_gettext.dll;extension=php_gmp.dll;extension=php_ifx.dll;extension=php_imap.dll;extension=php_interbase.dll;extension=php_ldap.dll;extension=php_mbstring.dll;extension=php_mcrypt.dll;extension=php_mhash.dll;extension=php_mime_magic.dll;extension=php_ming.dll;extension=php_msql.dll;extension=php_mssql.dllextension=php_mysql.dllextension=php_mysqli.dll;extension=php_oci8.dll;extension=php_openssl.dll;extension=php_pdo.dll;extension=php_pdo_firebird.dll;extension=php_pdo_mssql.dll;extension=php_pdo_mysql.dll;extension=php_pdo_oci.dll;extension=php_pdo_oci8.dll;extension=php_pdo_odbc.dll;extension=php_pdo_pgsql.dll;extension=php_pdo_sqlite.dll;extension=php_pgsql.dll;extension=php_pspell.dll;extension=php_shmop.dll;extension=php_snmp.dll;extension=php_soap.dll;extension=php_sockets.dll;extension=php_sqlite.dll;extension=php_sybase_ct.dll;extension=php_tidy.dll;extension=php_xmlrpc.dll;extension=php_xsl.dll;extension=php_zip.dll

My phpinfo has this next to the path:

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Common Files\Roxio Shared\9.0\DLLShared\;C:\Program Files\MySQL\MySQL Server 5.0\bin;c:\php\ext;

Is there anything else I should look for?I've read that older versions of MySQL come ready configured for use with php, and that the newest, 5.3, sometimes sorts this problem. What is mssql and mssqli, and should they also be uncommented, or is that for Microsoft's proprietary SQL?

Link to comment
Share on other sites

It looks like the extension dir should be set to c:\php\ext. Make sure the path to php.ini that you see in phpinfo is actually the version of php.ini that you're editing, it will tell you which php.ini it's actually using, make sure that's the one you're editing. The mssql extension is for Microsoft SQL Server.

Link to comment
Share on other sites

I changed the path back to c:/php because that's where it should be, I just pointed to the /ext directory as a test. I'm still not sure what's going on. The php.ini file is definately in c:/php. Here is a completely copy of the phpinfo page.Sorry to keep repeating myself, and thanks for the time and effort, as always. I really need to learn about the workings of these things and not just hope or rely on others to fix stuff for me.

Link to comment
Share on other sites

I don't think it's finding php.ini.

Configuration File (php.ini) Path C:\Windows
I've never seen that just give a directory, usually it gives the full path (including "php.ini"). Copy php.ini to c:\windows, that's where it's looking for it. If you've changed a lot of things in php.ini you might want to start over with a fresh copy of it and start over with the edits. Edited by justsomeguy
Link to comment
Share on other sites

There is definately a copy of php.ini in the c:/windows folder, and I found a second .dll file in the list with mysql in the name (extension=php_pdo_mysql.dll) and I uncommented that just in case it was important to do so. I restarted and still nothing. I changed the extensions directly back to ./ext. I may start again. I followed the directions in Sams Teach Yourself PHP, MySQL & Apache and really it seems like it should've worked. You'd think that the versions shipped with the book would work with their instructions. I hate computers sometimes.

Link to comment
Share on other sites

Okay, I just want to talk through the steps that my book suggests, to see if there are any glaring holes anyone can spot.

  1. Install and configure MySQL 5.0
    • Run *.msi file
    • Select Typical installation and open Config wizard
    • Select Detailed configuration
    • Select Developer Machine
    • Choose Multifunctional Database
    • Select default Installation Path
    • Enable TCP/IP and opt for standard 3306 port, enabling strict mode
    • Choose character set and install as a service, and make MySQL available on the windows PATH
    • Enter a new password for the root account and hit Execute

[*]Install and configure Apache 2.2

  • Run Apache installer
  • Enter domain and full network address and administrator's email address, and opt to run Apache as a service
  • Choose Typical Installation

[*]Install and configure PHP 5.2

  • Extract files to c:/php
  • Add PHP to the Windows PATH
  • Make a copy of php.ini-recommended file, saving it as php.ini
  • In Apache's httpd.conf file, add LoadModule php5_module c:/php/php5apache2_2.dll and PHPIniDir "C:/php/"
  • Also, add AddType Application/x-httpd-php.php .php .html

  • Uncomment mysql and mysqli lines in php.ini

Am I missing anything? Are there more steps or is that it?

Link to comment
Share on other sites

Further: I found a page at the end of the php manual about loading extensions in Windows, and a few people mention the problem I'm having and a variety of fixes. I added the Environment variable PHPRC and the c:/php value. The problem, as you mentioned before, JSG, is that the phpinfo page points to the correct directory for the php.ini file, but it isn't reading it (Configuration File (php.ini) Path ¦ (none). So it is loading a default (where on earth is the default stored?).It's driving me kerazzy.

Link to comment
Share on other sites

Finally! I deleted every php.ini file (I had littered my C drive with them, as every possible fix suggested a new location for it) and made a new one and changed Apache's httpd file to look for the php.ini file in the windows folder (where it seemed to want to look anyway), and voila. Well, I say voila because my mysql test connection file didn't spit any errors - I haven't made any queries yet...

Link to comment
Share on other sites

In future, just use XAMPP or Wamp installers.
I tried using a wamp installer and it didn't work either, for whatever reason. It's fixed now. Well, my php scripts to connect to MySQL aren't working, but at least I know I'm using the right php.ini file and I'm not getting errors. Kind of wish I were, though, would make it easier to know what's going wrong.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...