如何将MySQL转换为mysqli?基于下面的代码,我如何将其转换为mysqli?是否就像更改*mysql_query($sql)一样简单?;到mysqli_query($SQL); ?**<?PHP//in my header file that is included on every page I have this$DB["dbName"] = "emails";$DB["host"] = "localhost";$DB["user"] = "root";$DB["pass"] = "";$link = mysql_connect($DB['host'], $DB['user'], $DB['pass']) or die("<center>An Internal Error has Occured. Please report following error to the webmaster.<br><br>".mysql_error()."'</center>");mysql_select_db($DB['dbName']);// end header connection part// function from a functions file that I run a mysql query through in any page.function executeQuery($sql) { $result = mysql_query($sql); if (mysql_error()) { $error = '<BR><center><font size="+1" face="arial" color="red">An Internal Error has Occured.<BR> The error has been recorded for review</font></center><br>'; if ($_SESSION['auto_id'] == 1) { $sql_formatted = highlight_string(stripslashes($sql), true); $error .= '<b>The MySQL Syntax Used</b><br>' . $sql_formatted . '<br><br><b>The MySQL Error Returned</b><br>' . mysql_error(); } die($error); } return $result;}// example query ran on anypage of the site using executeQuery function$sql='SELECT auto_id FROM friend_reg_user WHERE auto_id=' .$info['auto_id'];$result_member=executequery($sql);if($line_member=mysql_fetch_array($result_member)){ extract($line_member);} else { header("location: index.php"); exit;}?>
3 回答
繁华开满天机
TA贡献1816条经验 获得超4个赞
mysql_*
mysqli_*
mysql_connect
将由 mysql_error
将由 和/或 ,取决于上下文 mysql_query
将由 诸若此类
对于MySQL,您必须使用 连接后,指示要在哪个数据库上执行查询。 另一方面,mysqli允许您将数据库名指定为第四个参数 尽管如此,也有一个 函数,如果您愿意的话,可以使用。
手掌心
TA贡献1942条经验 获得超3个赞
mysql_*
mysqli_*
mysqli_*
mysql_query($query)
mysqli_query($link, $query)
MMTTMM
TA贡献1869条经验 获得超4个赞
$con = mysqli_connect($serverName,$dbusername,$dbpassword);
所有“ MySQL_SELECT_db(
“有” mysqli_select_db($con)"
所有“ MySQL查询(
“有” mysqli_query($con)
“和 所有“ MySQL
“有” mysqli".
添加回答
举报
0/150
提交
取消