PHP:未定义的函数mysql_connect()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34557221/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP : Undefined function mysql_connect()
提问by FrostyPinky
I just downloaded the new xampp
and try to run my old projects and I got this error
我刚刚下载了新项目xampp
并尝试运行我的旧项目,但出现此错误
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in F:\xampp\htdocs\try\index.php:17 Stack trace: #0 {main} thrown in F:\xampp\htdocs\try\index.php on line 17
Does it mean that the mysql_connect
that I used is not already supported in new xampp ?
这是否意味着mysql_connect
新 xampp 不支持我使用的?
回答by Evochrome
mysql_connect()
has been removed from PHP7, which is used by the newest xampp version.
已从最新的 xampp 版本使用的 PHP7 中删除。
Instead, use mysqli_connect()like in this example.
相反,使用mysqli_connect()就像在这个例子中一样。
Another method, PDOis also possible (but is coded in a very different way as mysql_connect.)
另一种方法,PDO也是可能的(但与 mysql_connect 以非常不同的方式编码。)
回答by devpro
The MySQL module is depreciated in PHP5
and removed in PHP7, you can use these:
MySQL 模块PHP5
已在 PHP7 中折旧和删除,您可以使用这些:
Check your version by using phpinfo()
.
使用phpinfo()
.
回答by Atilla Arda A??kg?z
Not particularly by xamppp but php itself deprecated mysql Here a quote from them:
不是特别是 xamppp,而是 php 本身弃用了 mysql 这里是他们的引述:
The original MySQL extension is now deprecated, and will generate E_DEPRECATED errors when connecting to a database. Instead, use the MySQLi or PDO_MySQL extensions
原始 MySQL 扩展现已弃用,并且在连接到数据库时会生成 E_DEPRECATED 错误。相反,使用 MySQLi 或 PDO_MySQL 扩展
if you can provide us php version i can help more
如果你能提供给我们 php 版本,我可以提供更多帮助