The mysql extension is deprecated [duplicate]

2019-09-27 15:53发布

This question already has an answer here:

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');
?>

Here im using "mysql_connect". When i run it, it says that this extension deprecated/outdated and that i have to use "mysqli_connect".

So now i'm just using the same code as above, but just with the "i" at the end instead.

What am I doing wrong?

In advance, thanks!

PS: My first language is NOT english. Hope you will understand it.

3条回答
成全新的幸福
2楼-- · 2019-09-27 16:04

mysqli_select_db parameters are different. Read their documentation: http://us3.php.net/manual/en/mysqli.select-db.php

查看更多
女痞
3楼-- · 2019-09-27 16:19

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'");


?>

ex. of mysqli query^^

查看更多
Rolldiameter
4楼-- · 2019-09-27 16:30

You are using mysql_connect.You must replace it with mysql_connect and learn about its functions.

This link would be a nice read

查看更多
登录 后发表回答