![](/img/trans.png)
[英]Getting an error Fatal error: Call to undefined function mysqli_connect()
[英]Getting an mysqli_connect function undefined in error log file of server
我有一个网站,当我尝试访问某个从数据库中获取数据的页面时,我遇到内部服务器错误500。当我检查错误的日志文件时,它说mysqli_connect() function undefined
这是我与数据库
<?php
$connection = mysqli_connect("localhost","root","","gull");
if(!$connection){
echo "Error";
}
?>
我试图从数据库中获取数据的页面代码如下所示。
<?php
$page = "typo";
include_once('admin/database.php');
include_once('include/header.php');
?><div class="breadcrumbs">
<div class="container">
<div class="breadcrumbs-main">
<ol class="breadcrumb">
<li><a href="index.php" style="color:#DAA520;">Home</a></li>
<li class="active">Behind the Scenes</li>
</ol>
</div>
</div>
</div>
<!--typo-starts-->
<div class="gallery">
<div class="container">
<div class="gallery-top heading">
<h2 class="family">Behind the Scenes</h2>
</div>
<div class="gallery-bottom">
<div class="row">
<?php
$select="select * from bti";
$run=mysqli_query($connection,$select);
while($fetch=mysqli_fetch_assoc($run)):
?>
<div class="col-md-3 portfolio-item" style="margin-top:1em;">
<a href="bti/<?php echo $fetch['path'];?>" data-lightbox="<?php echo $fetch['path'];?>" data-title="">
<img class="img-responsive " src="bti/<?php echo $fetch['path'];?>" alt="" width="100%">
</a>
</div>
<?php
endwhile;
?>
</div>
</div>
</div>
</div>
<!--typo-ends-->
<!--footer-starts-->
<?php
include_once('include/footer.php');
?>
这些是某种服务器错误还是我的代码内有任何错误?
注意:这些说明适用于Windows
如果不存在函数mysqli_connect()
,这是因为在您的PHP安装中未启用MySQLi扩展 。 要启用它,请执行以下操作:
1.找到您的php.ini
文件的位置。 执行:
<?php
phpinfo();
exit;
查找“ Loaded Configuration File
”行,并记下Loaded Configuration File
的路径。 那就是php.ini
2.在任何文本编辑器中打开配置文件,然后搜索php_mysqli
。 您应该找到类似于以下内容的行:
;extension=php_mysqli.dll
通过删除分号取消注释该行;
在它前面。
3.重新启动您的网络服务器
问题解决了...这是数据中心提供的错误,托管服务提供商告诉了我,所以我在这里发布了这些答案,以便将来可能对其他人有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.