Changing this from MySQL to MySQLi?(将其从 MySQL 更改为 MySQLi?)
问题描述
我决定改用 MySQLi,因为有人告诉我它更安全.我真正感到困惑的是新的扩展.我尝试在每个 mysql 之后添加 'i',但这给了我一大堆错误.我在 PHP 手册中查找了为什么会发生这种情况,还有一大堆其他功能.老实说,我不知道如何转换.你能帮我吗?
I've decided to switch to MySQLi, because some people have told me it's more secure.. What I'm really confused about, is the new extensions. I tried just added 'i' after every mysql, but that gave me a crap load of errors. I looked up in the PHP manual why that was happening and there was a whole bunch of other functions.. I honestly can't figure out how to convert. Can you help me out?
include("dbinfo.php");
mysql_connect($c_host,$c_username,$c_password);
@mysql_select_db($c_database) or die(mysql_error());
$mycon = new mysqli($c_host, $c_username, $c_password, $c_database);
$query="SELECT * FROM users WHERE username='" .$_COOKIE['username']. "'";
$result=mysql_query($query) or die(mysql_error());
$num=mysql_numrows($result);
$username=mysql_result($result,$i,"username");
推荐答案
以下是您需要做的:
阅读概述,以便了解差异/优势.
Read the overview so that have an understanding of the differences/advantages.
查阅old -> new function summaryPHP 站点并使用 mysqli 接口启动和运行现有代码.
Consult the old -> new function summary on the PHP site and get your existing code up and running with the mysqli interface.
利用改进(例如使用准备好的语句) 否则这是徒劳的.(默认情况下,mysqli 确实并不比 mysql 更安全.)
Take advantage of the improvements (such as using prepared statements) otherwise this is a futile exercise. (By default mysqli really isn't any more secure than mysql.)
这篇关于将其从 MySQL 更改为 MySQLi?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将其从 MySQL 更改为 MySQLi?
基础教程推荐
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php中的PDF导出 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- php中的foreach复选框POST 2021-01-01
- Web 服务器如何处理请求? 2021-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
