dongpin2969 2015-02-12 14:28
浏览 20

MySQL错误:在第4行调用未定义的函数mysql_connect()[file]

I keep getting this error, and i do not know much about PHP, but I would like to get started with it and with MySQL, but this error stops me from continueing with my learning!

Info
Server Program: Niginx
Installed Extras: PHP [5.6.4] | MySQL

Files:

<?php include "includes/config.php"; ?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" style+"text/css" href="css/main.css" />
<script type="text/javascript" language="javascript" src="javascript/main.js"></script>

</head>

<body>

</body>
</html>

config.php:

<?php

//connect to database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("chat") or die(mysql_error());

echo "Working";
?>
  • 写回答

1条回答 默认 最新

  • dou2347 2015-02-12 14:43
    关注

    I assume you are following an old tutorial on connecting to MySQL databases.

    The library for commands beginning with mysql_ is deprecated. This that you shouldn't be using when writing code in php, as it will be "turned off" in the future. Take a look at the mysql_connect() command's documentation for more information.

    Thankfully, there's a number of alternative ways for you to connect to a database, which aren't going to be turned off any time soon! The one I'd recommend in your situation for simplicity is the mysqli_ library. Looks pretty similar, right? You use it in a fairly similar way too, check the documentation for mysqli_connect().

    Converting your mysql_ commands to mysqli_ is not hard, take a look at this answer for some more help.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题