热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

致命错误:未找到类“MySQLi”。-Fatalerror:Class'MySQLi'notfound

Iamdoingatutorialandamgettingthiserror:我正在做一个教程,并得到这个错误:Fatalerror:ClassMySQLin

I am doing a tutorial and am getting this error:

我正在做一个教程,并得到这个错误:

Fatal error: Class 'MySQLi' not found (LONG URL) on line 8

致命错误:在第8行没有找到(长URL)类的MySQLi。

The code on line 8 is:

第8行的代码是:

$mysqli = new MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error());

I saw online someone said to see if it was turned on in my phpinfo(), but there wasn't anything listed in there under for "mysqli".

我在网上看到有人说,我的phpinfo()上是否打开了它,但在那里没有任何东西被列入“mysqli”。

Also, I am running PHP version 5.2.5

另外,我正在运行PHP 5.2.5版本。

14 个解决方案

#1


63  

Sounds like you just need to install MySQLi.

听起来你只是需要安装MySQLi。

If you think you've done that and still have a problem, please post your operating system and anything else that might help.

如果你认为你已经做了,并且仍然有问题,请发布你的操作系统和其他可能的帮助。

#2


41  

You can check if the mysqli libraries are present by executing this code:

您可以通过执行以下代码检查mysqli库是否存在:

if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
    echo 'We don\'t have mysqli!!!';
} else {
    echo 'Phew we have it!';
}

#3


34  

If you are on Ubuntu, run:

如果你在Ubuntu上运行:

 sudo apt-get install php5-mysqlnd

#4


10  

If you're calling "new mysqli(..)" from within a class that is namespaced, you might see a similar error Fatal error: Class 'foo\bar\mysqli' not found in. The way to fix this is to explicitly set it to the root namespace with a preceding backslash like so:

如果您在一个带有名称空间的类中调用“new mysqli(..)”,您可能会看到类似的错误:类“foo\bar\mysqli”。解决这一问题的方法是将其显式地设置为根名称空间,前面有一个反斜杠,如下所示:

#5


8  

In addition to uncommenting the php_mysqli.dll extension in php.ini, also uncomment the extension_dir directive in php.ini and specify your location:

除了取消对php_mysqli的注释。dll在php扩展。ini,也取消了php的extension_dir指令。ini并指定您的位置:

extension_dir = "C:\software\php\dist\ext"

This made it work for me.

这使它对我起作用。

#6


5  

My OS is Ubuntu. I solved this problem by using:

我的操作系统是Ubuntu。我用以下方法解决了这个问题:

sudo apt-get install php5-mysql

#7


2  

Seems like problem with your installation.

看来你的安装有问题。

  • Have you installed MySQLi?
  • 你安装MySQLi吗?
  • Have you activated it in php.ini?
  • 你把它激活了吗?

http://www.php.net/manual/en/mysqli.installation.php

http://www.php.net/manual/en/mysqli.installation.php

#8


1  

You can use a handwritten MYSQLi class, so you don't need to install mysqli. It's the only solution if you don't own the server.

您可以使用一个手写的MYSQLi类,因此您不需要安装MYSQLi。如果你不拥有服务器,这是唯一的解决方案。

#9


1  

I thought I might help anybody with the same problem using Namesco servers. I have been trying to fix this problem after moving a database from my local server on home pc to namesco. They would not assist they said it was a coding issue.

我想我可以用Namesco服务器来帮助任何人解决同样的问题。我一直在试图解决这个问题,从我的本地服务器上的本地服务器到namesco。他们不会帮助他们说这是一个编码问题。

  • However, it was simple to fix from their CPANEl LINUX hosting interface.
  • 但是,从他们的CPANEl LINUX主机接口中进行修复很简单。
  • Click on php.
  • 单击php。
  • then click on php modules and from their list of preinstalled modules just click the box for mysqli.
  • 然后单击php模块,并从它们的预安装模块列表中单击mysqli的复选框。
  • Then click save. (No need to change code if it worked(s) on another server.)
  • 然后单击save。(如果它在另一台服务器上工作,不需要更改代码。)

Unfortunately, their support articles were a waste of time. After reading this I went to admin interface with a new determination.

不幸的是,他们的支持文章是在浪费时间。读完这篇文章后,我用新的决心去管理界面。

Thank you, everybody.

谢谢你,每一个人。

#10


0  

Some distributions (such as Gentoo) support multiple installations of PHP, and you have to make sure you're using one with mysqli installed and enabled.

一些发行版(比如Gentoo)支持PHP的多个安装,并且您必须确保使用的是mysqli安装和启用的。

On Gentoo, I had installed a new PHP (with the mysqli USE flag enabled), but I needed to activate the new version of PHP (since the old one must have been missing mysqli):

在Gentoo上,我安装了一个新的PHP(启用了mysqli使用标志),但我需要激活新版本的PHP(因为旧版本肯定是丢失了mysqli):

# eselect php list apache2
  [1]   php5.3 *
  [2]   php5.5
# eselect php set apache2 2
You have to run `/etc/init.d/apache2 restart' for the changes to take effect
# /etc/init.d/apache2 restart

#11


0  

host, $this->user, $this->pass, $this->db);

            if (mysqli_connect_error()) {
                die('Connect Error (' . mysqli_connect_errno() . ') ' .
                    mysqli_connect_error());
            }
        }
    }
?>

#12


0  

This solved the initial 'not found' error for me. Note the backslash, works like a dream now. Only necessary when using a namespace but who doesn't nowadays?

这解决了初始的“未发现”错误。注意反斜杠,现在就像一个梦。只有在使用名称空间时才有必要,但现在谁不使用呢?

$mysqli = new \MySQLi($db_server, $db_user, $db_pass, $db_name) or die(mysqli_error());

$mysqli = new \ mysqli ($db_server, $db_user, $db_pass, $db_name)或die(mysqli_error());

#13


0  

I checked all above and it didn't work for me,

我检查了上面所有的东西,它对我没用,

There are some steps I found.

我发现了一些步骤。

I used PHP Version 5.5.9-1ubuntu4.17 on Ubuntu 14.04

我在Ubuntu 14.04上使用了PHP 5.5.9-1ubuntu4.17。

First check the folder

首先检查文件夹

#ls /etc/php5/mods-available/
json.ini  mcrypt.ini  mysqli.ini  mysql.ini  mysqlnd.ini  opcache.ini  pdo.ini  pdo_mysql.ini  readline.ini  xcache.ini

If it did not contain mysqli.ini, read other answer for installing it,

如果它不包含mysqli。ini,请阅读其他安装它的答案,

Open php.ini find extension_dir

打开php。ini找到extension_dir

In my case , I must set extension_dir = /usr/lib/php5/20121212

在我的例子中,我必须设置extension_dir = /usr/lib/php5/20121212。

And restart apache2 : /ect/init.d/apache2 restart

并重新启动apache2: /ect/init。d /输入重启

#14


0  

The PHP zip includes most of the commonly used extensions (*.dll on windows such as php_mysqli.dll) under the \ext directory, however they are not enabled by default. You might be getting this Fatal Error when trying to use MySQLi:

PHP zip包含了大多数常用的扩展(*。在\ext目录下的windows上的dll(如php_mysqli.dll),但是默认情况下是不启用的。在尝试使用MySQLi时,您可能会遇到这个致命错误:

( ! ) Fatal error: Uncaught Error: Class 'mysqli' not found in C:\myProject\ class.Database.php on line 24

To enable extensions, open php.ini (you might need to first copy php.ini-development as php.ini), and un-comment (or add) these two lines:

要启用扩展,请打开php。ini(您可能需要首先复制php)。作为php.ini),和un-comment(或添加)这两行:

extension_dir = "ext"

And any particular extensions you are getting Fatal Errors for, i.e. for mysqli:

任何特定的扩展都有致命错误,比如mysqli:

extension=mysqli

推荐阅读
  • 在Kubernetes上部署JupyterHub的步骤和实验依赖
    本文介绍了在Kubernetes上部署JupyterHub的步骤和实验所需的依赖,包括安装Docker和K8s,使用kubeadm进行安装,以及更新下载的镜像等。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 本文详细介绍了SQL日志收缩的方法,包括截断日志和删除不需要的旧日志记录。通过备份日志和使用DBCC SHRINKFILE命令可以实现日志的收缩。同时,还介绍了截断日志的原理和注意事项,包括不能截断事务日志的活动部分和MinLSN的确定方法。通过本文的方法,可以有效减小逻辑日志的大小,提高数据库的性能。 ... [详细]
  • 学习SLAM的女生,很酷
    本文介绍了学习SLAM的女生的故事,她们选择SLAM作为研究方向,面临各种学习挑战,但坚持不懈,最终获得成功。文章鼓励未来想走科研道路的女生勇敢追求自己的梦想,同时提到了一位正在英国攻读硕士学位的女生与SLAM结缘的经历。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • 本文介绍了Redis的基础数据结构string的应用场景,并以面试的形式进行问答讲解,帮助读者更好地理解和应用Redis。同时,描述了一位面试者的心理状态和面试官的行为。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • 本文介绍了一个在线急等问题解决方法,即如何统计数据库中某个字段下的所有数据,并将结果显示在文本框里。作者提到了自己是一个菜鸟,希望能够得到帮助。作者使用的是ACCESS数据库,并且给出了一个例子,希望得到的结果是560。作者还提到自己已经尝试了使用"select sum(字段2) from 表名"的语句,得到的结果是650,但不知道如何得到560。希望能够得到解决方案。 ... [详细]
  • 本文详细介绍了Spring的JdbcTemplate的使用方法,包括执行存储过程、存储函数的call()方法,执行任何SQL语句的execute()方法,单个更新和批量更新的update()和batchUpdate()方法,以及单查和列表查询的query()和queryForXXX()方法。提供了经过测试的API供使用。 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • Ubuntu安装常用软件详细步骤
    目录1.GoogleChrome浏览器2.搜狗拼音输入法3.Pycharm4.Clion5.其他软件1.GoogleChrome浏览器通过直接下载安装GoogleChro ... [详细]
  • mysql-cluster集群sql节点高可用keepalived的故障处理过程
    本文描述了mysql-cluster集群sql节点高可用keepalived的故障处理过程,包括故障发生时间、故障描述、故障分析等内容。根据keepalived的日志分析,发现bogus VRRP packet received on eth0 !!!等错误信息,进而导致vip地址失效,使得mysql-cluster的api无法访问。针对这个问题,本文提供了相应的解决方案。 ... [详细]
author-avatar
手机用户2502860901
这个家伙很懒,什么也没留下!
RankList | 热门文章