PHP Fatal error: Class 'MySQLi' not found

Problems with the Linux version of XAMPP, questions, comments, and anything related.

PHP Fatal error: Class 'MySQLi' not found

Postby deepshikha » 21. December 2016 11:04

I am using Xampp (xampp-linux-x64-7.0.13-0) on linux. I am not able to connect to mysql database through php code.I got error PHP Fatal error: Class 'MySQLi' not found in /opt/lampp/htdocs/test5/connection.php on line 3. here is the code:
<?php // sqltest.php
require_once 'login5.php';
$conn = new \MySQLi($hn, $un, $pw, $db);
if ($conn->connect_error) die($conn->connect_error);

if (isset($_POST['delete']) && isset($_POST['isbn']))
{
$isbn = get_post($conn, 'isbn');
$query = "DELETE FROM classics WHERE isbn='$isbn'";
$result = $conn->query($query);
if (!$result) echo "DELETE failed: $query<br>" .
$conn->error . "<br><br>";
}

if (isset($_POST['author']) &&
isset($_POST['title']) &&
isset($_POST['category']) &&
isset($_POST['year']) &&
isset($_POST['isbn']))
{
$author = get_post($conn, 'author');
$title = get_post($conn, 'title');
$category = get_post($conn, 'category');
$year = get_post($conn, 'year');
$isbn = get_post($conn, 'isbn');
$query = "INSERT INTO classics VALUES" .
"('$author', '$title', '$category', '$year', '$isbn')";
$result = $conn->query($query);

if (!$result) echo "INSERT failed: $query<br>" .
$conn->error . "<br><br>";
}

echo <<<_END
<form action="sqltest.php" method="post"><pre>
Author <input type="text" name="author">
Title <input type="text" name="title">
Category <input type="text" name="category">
Year <input type="text" name="year">
ISBN <input type="text" name="isbn">
<input type="submit" value="ADD RECORD">
</pre></form>
_END;

$query = "SELECT * FROM classics";
$result = $conn->query($query);
if (!$result) die ("Database access failed: " . $conn->error);

$rows = $result->num_rows;

for ($j = 0 ; $j < $rows ; ++$j)
{
$result->data_seek($j);
$row = $result->fetch_array(MYSQLI_NUM);

echo <<<_END
<pre>
Author $row[0]
Title $row[1]
Category $row[2]
Year $row[3]
ISBN $row[4]
</pre>
<form action="sqltest.php" method="post">
<input type="hidden" name="delete" value="yes">
<input type="hidden" name="isbn" value="$row[4]">
<input type="submit" value="DELETE RECORD"></form>
_END;
}

$result->close();
$conn->close();

function get_post($conn, $var)
{
return $conn->real_escape_string($_POST[$var]);
}
?>

I struck badly on this step I have removed semicolon in front of extension=php_mysqli.so in php.ini but no use. Please help me if somebody have solution.
deepshikha
 
Posts: 7
Joined: 21. December 2016 10:59
XAMPP version: xampp-linux-x64-7.0.13-0
Operating System: linux

Re: PHP Fatal error: Class 'MySQLi' not found

Postby Nobbie » 21. December 2016 13:02

>I struck badly on this step I have removed semicolon in front of extension=php_mysqli.so in php.ini but no use. Please help me if somebody have solution.

There is NO(!) such line in php.ini (/opt/lampp/etc/php.ini) and it would also be wrong to remove the semicolon, as MySQLi is statically linked into the PHP module. Which php.ini do you mean (as there is no php_mysqli.so in Xampp) and are you sure you are running Xampp?
Nobbie
 
Posts: 9628
Joined: 09. March 2008 13:04

Re: PHP Fatal error: Class 'MySQLi' not found

Postby deepshikha » 21. December 2016 13:06

yes i am running Xampp, you are right there is no file with name php_mysqli.so in xampp but in php.in you can find this line extension=php_mysqli.so
deepshikha
 
Posts: 7
Joined: 21. December 2016 10:59
XAMPP version: xampp-linux-x64-7.0.13-0
Operating System: linux

Re: PHP Fatal error: Class 'MySQLi' not found

Postby deepshikha » 21. December 2016 13:07

and I am talking about php.ini (/opt/lampp/etc/php.ini) only,
do you have any idea why I am getting this error?PHP Fatal error: Class 'MySQLi' not found
deepshikha
 
Posts: 7
Joined: 21. December 2016 10:59
XAMPP version: xampp-linux-x64-7.0.13-0
Operating System: linux

Re: PHP Fatal error: Class 'MySQLi' not found

Postby Nobbie » 21. December 2016 13:26

deepshikha wrote:but in php.in you can find this line extension=php_mysqli.so


No!

There is NO line which contains php_mysqli.so in php.ini (there is only one line " extension=php_mysqli.dll", but as you can see, it does have the wrong extension *.dll). If your php.ini contains an entry like "extension=php_mysqli.so", you must have overwritten php.ini by another version. I just installed a fresh xampp-linux-x64-7.0.13-0-installer.run
Nobbie
 
Posts: 9628
Joined: 09. March 2008 13:04

Re: PHP Fatal error: Class 'MySQLi' not found

Postby deepshikha » 22. December 2016 06:55

I uninstall xampp and freshly install xampp-linux-x64-7.0.13-0-installer.run and here is the part of php.ini file, and see here is .so file mention in this file
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; ... or under UNIX:
;
; extension=msql.so
;
; ... or with a path:
;
; extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
;
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
;
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll
;extension=php_fileinfo.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_phar.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_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll

;extension="zip.so"

;extension="sqlite.so"

;extension="radius.so"

;extension="pgsql.so"

; disabled in XAMPP 1.7.2 because incompatible with PHP 5.3.0
;extension="dbx.so"

;extension="ming.so"

;extension="ncurses.so"

;extension="dio.so"

;extension="interbase.so"

; disabled in XAMPP 1.7.2 because incompatible with PHP 5.3.0
;extension="eaccelerator.so"
;eaccelerator.shm_size="16"
;eaccelerator.cache_dir="/opt/lampp/temp/eaccelerator"
;eaccelerator.enable="1"
;eaccelerator.optimizer="1"
;eaccelerator.check_mtime="1"
;eaccelerator.debug="0"
;eaccelerator.filter=""
;eaccelerator.shm_max="0"
;eaccelerator.shm_ttl="0"
;eaccelerator.shm_prune_period="0"
;eaccelerator.shm_only="0"
;eaccelerator.compress="1"
;eaccelerator.compress_level="9"

;oci8mark


;zend_extension=opcache.so
deepshikha
 
Posts: 7
Joined: 21. December 2016 10:59
XAMPP version: xampp-linux-x64-7.0.13-0
Operating System: linux

Re: PHP Fatal error: Class 'MySQLi' not found

Postby Nobbie » 22. December 2016 11:59

deepshikha wrote:I uninstall xampp and freshly install xampp-linux-x64-7.0.13-0-installer.run and here is the part of php.ini file, and see here is .so file mention in this file


Still no.

You explicitely said this:

"I have removed semicolon in front of extension=php_mysqli.so in php.ini but no use"

Please show me the line with ";extension=php_mysqli.so" where you removed the semicolon!? That is exactly what you said and i still cannot see such a line. Where is it?
Nobbie
 
Posts: 9628
Joined: 09. March 2008 13:04

Re: PHP Fatal error: Class 'MySQLi' not found

Postby deepshikha » 23. December 2016 11:42

There was no error in my php.ini file. the whole culprit was my IDE (eclips). the path of my php executable was not accurate that is why "PHP Fatal error: Class 'MySQLi' not found" was there. when I change my php executables' path to /opt/lampp/bin/php, error was removed.
thanks to all for response and support.
deepshikha
 
Posts: 7
Joined: 21. December 2016 10:59
XAMPP version: xampp-linux-x64-7.0.13-0
Operating System: linux

Re: PHP Fatal error: Class 'MySQLi' not found

Postby Nobbie » 23. December 2016 21:07

deepshikha wrote:the whole culprit was my IDE (eclips)


Horrible....

Instead of telling us about your IDE, you lied about php.ini and removing a semicolon before "extension=php_mysqli.so", what you never did. Hopefully you are feeling as bad as possible about this mega annoying "question". It is a pain in fact.

deepshikha wrote:thanks to all for response and support.


Hopefully the very last one. I wont ever answer to any of your lies.
Nobbie
 
Posts: 9628
Joined: 09. March 2008 13:04

Re: PHP Fatal error: Class 'MySQLi' not found

Postby Altrea » 23. December 2016 21:34

Sorry, but didn't you think that it is a very important information that your error message was displayed inside your IDE instead directly from the PHP interpreter?
Without this information it is impossible to guess the reason.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8892
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP Fatal error: Class 'MySQLi' not found

Postby deepshikha » 24. December 2016 07:54

yes you are right . error was on my part, I should have draft my question more carefully, but I was so panic that not able to figure out where is the problem. I will post next time more carefully.
deepshikha
 
Posts: 7
Joined: 21. December 2016 10:59
XAMPP version: xampp-linux-x64-7.0.13-0
Operating System: linux

Re: PHP Fatal error: Class 'MySQLi' not found

Postby Nobbie » 24. December 2016 11:44

deepshikha wrote: I should have draft my question more carefully, but I was so panic that not able to figure out where is the problem. I will post next time more carefully.


It is not only a question of being carefully, i doubted and asked you three times about php.ini, but you constantly insisted on your lie that you removed a semicolon in front of a line, which does not exist. That is, what i cannot understand. Why didnt you simply agree??
Nobbie
 
Posts: 9628
Joined: 09. March 2008 13:04

Re: PHP Fatal error: Class 'MySQLi' not found

Postby deepshikha » 25. December 2016 07:01

colored and bold line...If you can see.
why should I speak lie to you? PHP is new for me and got confused. thats all.
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; ... or under UNIX:
;
; extension=msql.so
;
; ... or with a path:
;
; extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it in its
; default extension directory.
;
; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.
;
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_exif.dll
;extension=php_fileinfo.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_phar.dll
;extension=php_pspell.dll
deepshikha
 
Posts: 7
Joined: 21. December 2016 10:59
XAMPP version: xampp-linux-x64-7.0.13-0
Operating System: linux

Re: PHP Fatal error: Class 'MySQLi' not found

Postby Nobbie » 25. December 2016 12:23

deepshikha wrote:colored and bold line...If you can see.
; extension=msql.so


This line is NOT:

; extension=mysqli.so

Do you want to tell me, that you really cannot see the difference between "msql" and "mysqli"?? I dont believe that. In your posting you always said "mysqli.so", never ever "msql.so". This is a MEGAHUGE difference.
Nobbie
 
Posts: 9628
Joined: 09. March 2008 13:04

Re: PHP Fatal error: Class 'MySQLi' not found

Postby JJ_Tagy » 25. December 2016 17:16

Semicolons make a big difference too.
JJ_Tagy
 
Posts: 724
Joined: 30. January 2012 13:44
Operating System: Windows 10 Pro x64

Next

Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 9 guests