【问题标题】:PHP and DB connections replace with mysqli from mysql [duplicate]PHP和DB连接替换为mysql中的mysqli [重复]
【发布时间】:2019-02-19 10:58:22
【问题描述】:
$con = mysql_connect("localhost", "root", "");  
$db = mysql_select_db("dbname", $con);
$q = "select*from tablename";
$qry = mysql_query($q);

你能帮我把这个mysql查询转换成mysqli吗

【问题讨论】:

  • 网上有很多解决方案
  • @Ashu - 在 SO 上有一个解决方案有什么问题?你有重复的参考吗?
  • @PaulSpiegel 这个问题在没有任何研究的情况下发布。
  • @Ashu - 几乎所有热门问题都是如此。 stackoverflow.com/questions/tagged/…

标签: php mysql mysqli


【解决方案1】:

使用喜欢

// mysqli_connect(host,username,password,dbname,port,socket);
$con = mysqli_connect("localhost", "root", "", "your_db");

// mysqli_select_db(connection, dbname);
$db = mysqli_select_db($con, "dbname");

$q = "select*from tablename";

// mysqli_query(connection,query,resultmode);
$qry = mysqli_query($con, $q);

参考以下文档

  1. PHP Mysqli

  2. w3schools Mysqli

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-13
    • 1970-01-01
    • 2013-12-06
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    相关资源
    最近更新 更多