Link to home
Start Free TrialLog in
Avatar of Overthere
Overthere

asked on

PHP v5.4 and Class 'mysqli' not found error

Hello folks,

   I upgraded to Web Expressions 4 from Web Matrix 3. I also upgraded my PHP from v5.3 to v5.4.
I checked in the applications option to ensure it had the right path for the php and it does.
But when I try to execute my page this is what I receive:

Fatal error: Class 'mysqli' not found in C:\Users\laptop\Documents\My Web Sites\SuppliersPHP\agentlogon.php on line 18

So I looked it up and mysqli should still be valid.
The web pages worked fine under PHP v5.3 in Web Matrix 3.
But I need to have Web Expression 4 working properly as its time to retire Web Matrix 3.
Can someone tell me what is wrong and how to fix it?
I really need PHP 5.4 and Web Expressions to work properly.
I also found a snippet of coding that test to see if mysqli is installed and it returns that it is not!
How can that be when I successfully used with PHP v5.3 in Web Matrix 3?

I have also included the entire section
<?php 
    require_once ("Includes/dbconfig.php");
    include("Includes/session.php");
   
    $baderr= "";

    if (isset($_POST['cancel']))
        {
           header ("Location: goodbye.php");
        }

    if (isset($_POST['submit']))
       {
           $username = $_POST['username'];
           $password = $_POST['password'];

        // create database connection
        $databaseConnection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
        if ($databaseConnection->connect_error)
          {
            die("Database selection failed: " . $databaseConnection->connect_error);

          }else{

             $query = "SELECT * FROM agents WHERE AgentUserName = '$username' AND AgentPassword = '$password'";

             $result = $databaseConnection->query($query);

            if ($result->num_rows > 0)
               {
              // output data
                while($row = $result->fetch_assoc())
                   {
                      //set up global session vars to be used thru out pages
                        $_SESSION["UserType"] ="A";
                        $_SESSION["AgentRecId"] = $row["RecId"];
                        $_SESSION["MsSqlAgentId"] = $row["AgentIdPk"];
                        $_SESSION["AgentFirstName"] = $row["FirstName"];
                        $_SESSION["AgentLastName"] = $row["LastName"];
                        $_SESSION["AgencyName"] = $row["AgencyName"];
                        $_SESSION["AgentEmail"] = $row["EmailAddress"];
                   }
                     // close database connection and redirect to agents menu
                        mysqli_close($databaseConnection);
                        header ("Location: agentmenu.php");
           } else {
               $baderr = "Username/password combination is incorrect. Please try again";
           }
       }
    }
?>

Open in new window

of coding below:
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Check in php.ini for a line containing:
extension=mysqli.so
or in Windows:
extension=php_mysqli.dll

If it's commented out, remove the ;, then restart your web server.

HTH,
Dan
Avatar of Overthere
Overthere

ASKER

I had checked the php.ini and removed the ; then restarted my IIS. I even rebooted. I am now receiving " PHP startup: Unable to load dynamic library c:\php\php_mysqli.dll"
I don't even have a file folder on c as PHP!

I made sure in Web Expression 4 that the application and site path for php was correct.
Its installed in C:\Program Files (x86)\php-5.4.45\php-cgi.exe

I then changed the php.ini - first to inserting the entire path and that resulted in it phewing.
And then uncommented to just:  extension=php_mysqli.dll
Still phews.

 What now?




I don't even have a file folder on c called "php"
Search for "php_mysqli.dll" on your computer.
here's what worked.
1. dragged my PHP folder to root (c:\)
2.adjusted my application and site options to that path
3. rechecked my php.ini

the error for mysqli.dll has disappeared but it is slower than a turtle. It was much,much faster in web Matrix 3. In addition, it now can not find pages. And the coding on pages are having a problem finding other pages. I use this:  
Any ideas on that one? this is discouraging.. I also noticed that when I create a website in web Expression, it does not appear in IIS 7 - why is that?
header("Location: agentmenu.php");

Open in new window

Here's what I did - I uninstall web Expression4. Reverted back to Web Matrix 3.
Made sure that in the php.in file that any reference in the extensions section for mysqli.dll, including pdo , was unchecked. Works better but still can get their examples to work. My previos sites that used php 5.3 work fine now too.
What gives?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree. I upgraded to 5.4 and depending on the components I am going to be using, I may upgrade to 5.6. Most of what I wrote in 5.3 was for demos and for myself as learning experience.
I did some more digging using IE and Chrome debugging options and it all points to the MySQL drivers. Haven't made a decision yet as to what I will do. I don't like MS Web Expression 4 - its buggy in my option. And Web Matrix 3 only supports  up PHP v5.5 - so I am kinda in a bind on that issue.
I like to be able to "preview" what the web page will render as a result of my PHP coding and as you know - some web developing packages don't handle that very well. Any suggestions?

Thank you again Ray for pointing me in the right path.
Check into Bitnami - they offer some virtual machine images that you can install on localhost.  I think you need a VMWare instance, but you can probably get that for free.