1

I have searched this error in Google and tried everything I found, but it still does not work. I have set in my php.ini

extension_dir ="C:\php\ext\"

uncommented

extension=php_mysql.dll
extension=php_mysqli.dll

these files are present in the extension path, and I restarted Apache. But phpinfo(); still does not show anything about MySQL. So do you have any suggestions to load these modules?

note: I am using Windows 7 (64 bit), MySQL 5.5, Apache 2.0.49 and PHP 5.3.16

void
  • 1,876
  • 8
  • 24
  • 30
  • 1
    Did you edit the correct php.ini? Look in `phpinfo()` to see which file path is actually being used for php.ini... – Michael Berkowski Aug 31 '12 at 19:20
  • 5
    The `mysql_*` functions are deprecated, if you're developing something new you should use `mysqli_*` functions or, better still, PDO. – Arjan Aug 31 '12 at 19:21
  • If I recall correct phpinfo tells you which configuration files got parsed. That might give you an additional hint. – arkascha Aug 31 '12 at 19:29
  • Yes Michael, i'm sure i'm in the correct file. thanks though. – void Aug 31 '12 at 19:48
  • Arjan, I tried, it gives the same error with mysqli. – void Aug 31 '12 at 19:49
  • **My Solution** I installed xampp and it worked, just in case somebody suffers from the same issue. thanks for all answers. – void Sep 16 '12 at 11:58
  • reference to https://stackoverflow.com/questions/17192442/php-ini-file-paths-dont-seem-to-work-right – 陳遠謀 Aug 08 '23 at 09:21

2 Answers2

2

Finally, I solved the same problem, so, here is my solution. I guess the last slash in the line

extension_dir ="C:\php\ext\

could make troubles. Just let it as

extension_dir ="C:\php\ext

Moreover, try to approach the problem the following way:

*My PC is running Windows 7 (Apache 2.2 & PHP 5.2.17 & MySQL 5.0.51a), the syntax in the file "httpd.conf" (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf) was sensitive to slashes. You can check if "php.ini" is read from the right directory. Just type in your browser "localhost/index.php". The code of index.php is the following: <?php echo phpinfo(); ?> There is the row (not far from the top) called "Loaded Configuration File". So, if there is nothing added, then the problem could be that your "php.ini" is not read, even you uncommented (extension=php_mysql.dll and extension=php_mysqli.dll). So, in order to make it work I did the following step. I needed to change from

PHPIniDir 'c:\PHP\'

to

PHPIniDir 'c:\PHP'

Pay the attention that the last slash disturbed everything!

Now the row "Loaded Configuration File" gets "C:\PHP\php.ini" after refreshing "localhost/index.php" (before I restarted Apache2.2) as well as mysql block is there. MySQL and PHP are working together!*

Darius Miliauskas
  • 3,391
  • 4
  • 35
  • 53
  • 1
    I had the exact same problem, I found 2 solutions: First it worked when I move `php.ini` file to `C:\Windows` folder which is the folder php.exe looks for its config file instead of the same folder. Or, second, it worked when I put `PHPIniDir "E:/PathTo/php56"` into `httpd.conf` file. – endo64 Nov 29 '16 at 14:24
0

I have been having the exact same problem as you. And I (literally) solved it 2 minutes ago.

I am running Apache 2.4 64 bit on Win 7.

The version of php I downloaded gave me two php.ini files:

1)php.ini-production and 2)php.ini-development

I thought that was all gravy and every time I made a change to one, I did the exact same thing to the other.

When I first encountered the problem I loaded index.php (on my local server) and looked at the sixth box from the top called "Loaded configuration file". It simple said "nothing."

I then referenced this page and found how PHP (once started) goes about looking for the php.ini file. I tried putting both the development and production (referenced above) files in all the directories that the above link specified. Nothing.

Then I thought, what the hell it's worth a shot, and changed the php.ini-production to just "php.ini".

Bam. It started working. Such a simplistic fix but I suppose it makes sense as to why Apache wasn't able to find "php.ini." The file didn't exist verbatim.

I really hope this helps, running into this problem sure sucked.

And I'm sorry if any of this seems patronizing because it is so simple. I always troubleshoot from this site and so many of the answers require more than a fundamental understanding of a subject, and since this seems like a problem(and a solution) that beginners will struggle with, I thought I would spell it out in a way that I would have appreciated 6 months ago.

user2980357
  • 11
  • 1
  • 2