我在一些项目中使用了以下函数,这是一个mysql查询,我试图将其转换为mysqli,代码如下
<?php
function jay_cms($database,$connection,$group,$id,$table="ps3_contents",$groupColumn= "ContentGroup",$IDColumn="ContentRefID",$valueColumn="ContentValue") {
mysql_select_db($database, $connection);
$query_CMSContent = "SELECT * FROM $table WHERE $groupColumn = '$group' AND $IDColumn = '$id'";
$CMSContent = mysql_query($query_CMSContent, $connection) or die(mysql_error());
$row_CMSContent = mysql_fetch_assoc($CMSContent);
$totalRows_CMSContent = mysql_num_rows($CMSContent);
mysql_free_result($CMSContent);
return $row_CMSContent[$valueColumn];
}
?>
然后我从数据库中按名称选择值,如下所示
<?php
echo jay_cms($database_localhost, $localhost, 'Footer Pages' , 'Privacy Policy');
?>
我的连接文件是
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_localhost = "localhost";
$database_localhost = "milehigh_milehighdata$";
$username_localhost = "root";
$password_localhost = "root";
$localhost = mysql_pconnect($hostname_localhost, $username_localhost, $password_localhost) or trigger_error(mysql_error(),E_USER_ERROR);
?>
我想在这里使用新的连接mysqli文件
<?php
# FileName="WADYN_MYSQLI_CONN.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_localhost_i = "localhost";
$database_localhost_i = "milehighdata";
$username_localhost_i = "root";
$password_localhost_i = "root";
@session_start();
$localhost_i = new mysqli($hostname_localhost_i, $username_localhost_i, $password_localhost_i, $database_localhost_i);
$localhost_i->set_charset('utf8');
?>