使用localhost中的php连接到db [英] Connection to db using php in localhost

查看:147
本文介绍了使用localhost中的php连接到db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我已经使用了LAMPP多次,这时候出了问题。当我访问浏览器(chrome)没有回波。这是我的代码:

Even if I have used LAMPP many times, this time something goes wrong. When I visit the browser(chrome) nothing echos. Here is my code:

index.php

<?php

error_reporting(E_ALL); /*after edit*/
$link = mysqli_connect('localhost', 'root', 'root', 'db');
if (!$link) {
    die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);

?>

我错过了什么吗?输出是什么。在我写我的文件

Do I miss something? The output is nothing. By the way i write my files in

$

我这样调用: localhost / my_pages 。简单的回波正在工作,php一般是罚款。我的数据库连接出现问题。

and i call it this way: localhost/my_pages. Simple echos are working and php in general is fine. Something goes wrong with my db connection.

推荐答案

感谢大家的回复!我发现了问题。出错了,mysqli在php中没有启用。这是为什么我有这个错误致命错误:调用未定义的函数mysqli_connect()在/var/www/html/diamond/index.php第8行我重新安装php和问题已解决:)

Thanks everyone for the response! I found the problem. Something went wrong and mysqli wasn't enabled in php. That's why i had this error Fatal Error:Call to undefined function mysqli_connect() in /var/www/html/diamond/index.php on line 8 I reinstalled php and problem solved :)

这篇关于使用localhost中的php连接到db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆