I'm teaching myself using various self-help books. Amazingly, I've gotten this far without asking for help, but now I'm stumped. I am a beginner, and don't understand many acronyms, so please be gentle in your response.

I installed Apache 5.2.2 on my Windows XP laptop, following instructions in beginner Apache/PHP/mySQL books. It works. I installed php 5.2.0, following same instructions. It works, and I've been able to complete all the exercises. I installed mySQL 5, following same instructions. It works too, and I was able to complete beginning exercises from the mysql prompt. Moving on to working with mysql through php failed miserably.

I created the following and named it mysqlconnect.php:
<?php
$mysqli = new mysqli();
?>
When I acces this through the browser (localhost:8080/mysqlconnect.php), I get the following error message: Class 'mysqli' not found in C:\Program Files\Apache Software Foundation\Apache 2.2\htdocs\mysqlconnect.php on line 2"

In trying to work through this myself, I have confirmed the following, which I suspect may or may not be relevant:

Per instructions in the books, in php.ini, I uncommented: extension=php_mysql.dll I added a line: extension=php_mysqli.dll

In looking at other settings in phpinfo. I find the following:
doc_root =
user_dir =
extension_dir = "./" (I suspect this might be the problem because the books say check this directive, without a clue what checking it might mean!)
Configuration Path (php.ini) Path: C:\php\php.ini
Server Root: C:/Program Files/Apache Software Foundation/Apache 2.2
Apache Environment: Path:C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\WINDOWS\system32\gs\gs7.05\bin;C:\Program Files\QuickTime\QTSystem\;C:\php;;C:\php;C:\Program Files\MySQL\MySQL Server 5.0\bin

Also, in response to the error message I copied mysqli.dll into the htdocs folder, but nothing changed.

I hope I've earned my spurs by getting this far on my 35-year-old liberal arts degree, but now I need encouragement. Your help, and explanations, will be unimaginably appreciated.

    Apparently the MySQL module is not installed with PHP5 by default. If you've installed the PHP manual (accessible from the Start Menu, if you have), you should be able to find the relevant installation information by going to Function Reference > MySQL Functions, and then reading the installation instructions for your platform (Windows).

    If you don't have the manual installed (or prefer to view it online) you can view the relevant page here.

    There is further discussion of this topic taking place in this thread, which you may find useful.

      Thank you. I followed all the instructions to deal with this issue, but couldn't get it to work, so I deleted everything and started over with different versions of apache, php and mysql. Everything is working, except I still can't seem to connect to mysql (mysqli?) through a php script, although at least now I get a blank screen without an error message. I'm going to work on it, then ask for help again if I can't figure it out.

        goldenbarker wrote:

        extension_dir = "./" (I suspect this might be the problem because the books say check this directive, without a clue what checking it might mean!

        The manual says this about that:

        ...extension_dir should be set to the directory where the PHP extensions are located. An example extension_dir value for PHP 5 is c:\php\ext

        Add that directory to your PATH string (which, btw, needs cleaning up).

        goldenbarker wrote:

        ...at least now I get a blank screen without an error message.

        That's not a good thing, and probably the only reason you're not seeing an error message is that display_errors is off by default on v5. For a learning/development system it should be turned on (either that or read your error log every time a script is run).

          Thank you. Here's my progress, and remaining problem. I deleted everything I could think of and reinstalled from a disk, with recent, but not the most recent, versions of Apache, MySql and PHP. (MySQL 5.0.22, Apache 2.0.58 and PHP 5.1.4). I checked everything I could. Apache is running as a service; so is MySQL. I can access MySQL through the mysql prompt, after entering my password. PHP info appears when I run http://localhost/phpinfo.php through browser. I renamed php.ini-recommended to php.ini. I used default settings for everything (local host, port 80, etc.) My self-help books are ambiguous about setting the extension directive in php.ini, but what I have at the moment is:
          extension=php_mysql.dll
          and
          extension=php_mysqli.dll.
          I set display_errors to "On"
          I followed the directions in the books to set up a simple connection, and got a blank page, so I reduced everything to the simplest form that seemed logical as "mysqlconnect.php" as follows:
          <?php
          $mysqli = new mysqli('localhost', 'root', '*******', 'mediator');
          if (mysqli_connect_error()) {
          echo "Boo";
          exit();
          } else {
          echo "Hi";
          }
          ?>
          For the password, I typed my actual password instead of the asterisks; the 'mediator' table is one that I created that works from the mysql command prompt.

          Then, I followed the suggestion to set extension_dir to c:\php\ext.

          The good news is that when I accessed mysqlconnect.php through the browser it said "Boo", but that's the bad news too, since I assume that I would have seen "Hi" if there weren't an error. No error report generated on screen, so I will have to figure out how to find an error log to look at.

          Specific and general questions:

          Any more suggestions for the specific problem?
          I would love to clean up PATH, but am uncertain what's safe to remove. If you know a resource that could teach me how to do this, it would be great.
          How do you "pros" make examples of your scripts (like mine above) display in colors and logically. I would be happy to make my questions easier to respond to by formatting them nicely, if I knew how.

          I used to think I was smart until I tackled this.
          Thanks in advance.

            After posting my long lament, I tried my little script again. Lo and Behold, my screen said "Hi." I've never been so pleased to be greeted! Hopefully, my big question has been answered and I can move on to Lesson 3. In the meantime, if someone knows how to clean up the PATH or format my questions to be easier to read, I would love to be directed to appropriate resources.

              When you make changes to php.ini you need to restart Apache for them to take effect. Probably you hadn't when you got booed. And that's likely why you didn't also get an error message.

              Setting extension_dir is more than a suggestion. The manual uses the word "require" in talking about the recommended configuration.

              To highlight php code: In the post composition page there's an icon above the edit box (far right) that says "php" with rollover text that says "Wrap [ PHP ] tags around selected text." Play with that.

              Your books may be good, but parts of them may be out of date. You should get very familiar with the manual and refer to it as a matter of course.

              Your PATH string contains a duplicate entry and a blank one. They should be easy to spot.

              Good luck.

                I really appreciate your help. I'm getting more familiar with the manuals - it's a steep learning curve. I am a better writer than I am a coder. If you have a slightly warped perspective on life, you may get a kick out of my dog's narrative of our joint progress from complete idiot to budding baby, tail-wagging, grey-haired geek. htttp://goldenbarker.home.comcast.net

                  Write a Reply...