[RESOLVED] mysqli fatal error: cannot instantiate non-existant class
Results 1 to 5 of 5

Thread: [RESOLVED] mysqli fatal error: cannot instantiate non-existant class

  1. #1
    Senior Member
    Join Date
    Oct 2002
    Location
    Oregon
    Posts
    244

    [RESOLVED] mysqli fatal error: cannot instantiate non-existant class

    I am trying to connect to MySQL and get the following Fatal Error:
    Fatal error: Cannot instantiate non-existent class: mysqli in C:\Documents and Settings\RLane\My Documents\Web Sites\Localhost\InDevelopment\Wellington\Source\11\results.php on line 26
    The code that is generating this is here:
    PHP Code:
    <html>
    <head>
      <title>Book-O-Rama Search Results</title>
    </head>
    <body>
    <h1>Book-O-Rama Search Results</h1>
    <?php
      
    // create short variable names
      
    $searchtype=$_POST['searchtype'];
      
    $searchterm=$_POST['searchterm'];

      
    $searchtermtrim($searchterm);

      if (!
    $searchtype || !$searchterm)
      {
         echo 
    'You have not entered search details.  Please go back and try again.';
         exit;
      }
      
      if (!
    get_magic_quotes_gpc())
      {
        
    $searchtype addslashes($searchtype);
        
    $searchterm addslashes($searchterm);
      }
    echo 
    "Searching for: $searchterm;
     
    $db = new mysqli('localhost''bookorama''bookorama123''books');
    For some reason it is choking on the
    $db = new mysqli('localhost', 'bookorama', 'bookorama123', 'books');
    line.

    I just loaded MySQL5 and I can access the database from the command line with mysql. Do I have to do something special to enable mysqli ?

  2. #2
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,855
    From http://www.php.net/mysqli:
    Requirements

    In order to have these functions available, you must compile PHP with support for the mysqli extension.

    Note: The mysqli extension is designed to work with the version 4.1.3 or above of MySQL. For previous versions, please see the MySQL extension documentation.

    Installation

    To install the mysqli extension for PHP, use the --with-mysqli=mysql_config_path/mysql_config configuration option where mysql_config_path represents the location of the mysql_config program that comes with MySQL versions greater than 4.1.

    If you would like to install the mysql extension along with the mysqli extension you have to use the same client library to avoid any conflicts.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Senior Member
    Join Date
    Oct 2002
    Location
    Oregon
    Posts
    244

    Totally lost now!

    Thanks for the post, but now I am totally lost...

    How do I activate the mysqli?
    Currently my php.ini where the MySQL stuff is configured like this:
    [MySQL]
    ; Allow or prevent persistent links.
    mysql.allow_persistent = On

    ; Maximum number of persistent links. -1 means no limit.
    mysql.max_persistent = -1

    ; Maximum number of links (persistent + non-persistent). -1 means no limit.
    mysql.max_links = -1

    ; Default port number for mysql_connect(). If unset, mysql_connect() will use
    ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
    ; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
    ; at MYSQL_PORT.
    mysql.default_port =3306

    ; Default socket name for local MySQL connects. If empty, uses the built-in
    ; MySQL defaults.
    mysql.default_socket =

    ; Default host for mysql_connect() (doesn't apply in safe mode).
    mysql.default_host =

    ; Default user for mysql_connect() (doesn't apply in safe mode).
    mysql.default_user =

    ; Default password for mysql_connect() (doesn't apply in safe mode).
    ; Note that this is generally a *bad* idea to store passwords in this file.
    ; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
    ; and reveal this password! And of course, any users with read access to this
    ; file will be able to reveal the password as well.
    mysql.default_password =

    ; Maximum time (in seconds) for connect timeout. -1 means no limit
    mysql.connect_timeout = 60

    ; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
    ; SQL-Errors will be displayed.
    mysql.trace_mode = Off
    Do I add something else in there or do I do it somewhere else in php.ini?

  4. #4
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,855
    This is what's in my php.ini file (Windows installation):
    Code:
    extension=php_mysqli.dll
    Code:
    [MySQLi]
    
    ; Maximum number of links.  -1 means no limit.
    mysqli.max_links = -1
    
    ; Default port number for mysqli_connect().  If unset, mysqli_connect() will use
    ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
    ; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look
    ; at MYSQL_PORT.
    mysqli.default_port = 3306
    
    ; Default socket name for local MySQL connects.  If empty, uses the built-in
    ; MySQL defaults.
    mysqli.default_socket =
    
    ; Default host for mysql_connect() (doesn't apply in safe mode).
    mysqli.default_host =
    
    ; Default user for mysql_connect() (doesn't apply in safe mode).
    mysqli.default_user =
    
    ; Default password for mysqli_connect() (doesn't apply in safe mode).
    ; Note that this is generally a *bad* idea to store passwords in this file.
    ; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")
    ; and reveal this password!  And of course, any users with read access to this
    ; file will be able to reveal the password as well.
    mysqli.default_pw =
    
    ; Allow or prevent reconnect
    mysqli.reconnect = Off
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  5. #5
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    14,855
    PS: if you change your php.ini, don't forget to restart Apache (or whatever webserver you're using).
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •