不推荐使用mysql扩展名 [英] The mysql extension is deprecated
问题描述
Aaalright,我真的需要一些帮助,因为我真的很困惑.我试图连接到phpmyadmin上的数据库.
Aaalright, i really need some help to this, because im really confused. Im trying to connect to a database on phpmyadmin.
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('test_database');
?>
这里我使用"mysql_connect".当我运行它时,它表明此扩展名已弃用/过时,并且我必须使用"mysqli_connect".
Here im using "mysql_connect". When i run it, it says that this extension deprecated/outdated and that i have to use "mysqli_connect".
所以现在我只是在使用与上面相同的代码,而只是在末尾加上"i".
So now i'm just using the same code as above, but just with the "i" at the end instead.
我做错了什么?
提前,谢谢!
PS:我的母语不是英语.希望你能理解.
PS: My first language is NOT english. Hope you will understand it.
推荐答案
Php已更改为mysqli,因此您将不得不使用mysqli而不是mysql. 在mysqli中,您不只是添加一个i就可以了. 阅读所有mysqli函数的内容 http://php.net/manual/zh/book.mysqli.php
Php has changed to mysqli, so you will have to use mysqli instead of mysql. In mysqli, you don't just add an i and it's done. Read this for all the mysqli functions http://php.net/manual/en/book.mysqli.php
<?php
$con = mysqli_connect('localhost', 'root', '', 'test_database');
mysqli_query($con, "UPDATE `table` SET id='1'");
?>
例如mysqli查询^^
ex. of mysqli query^^
这篇关于不推荐使用mysql扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!