我对 Mysql 和 PHP 完全陌生。我写了一个有效的脚本,但现在意识到我应该使用 mysqli 而不是 mysql。我尝试将所有 'mysql_...' 更改为 'mysqli_' 但没有奏效。谁能告诉我如何重写下面的代码?
$tableName = "Fixtures";
//==== CONNECT TO DATABASE
$con = mysql_connect($host,$user,$pass);
$dbs = mysql_select_db($databaseName, $con);
//==== FETCH DATA
$result = mysql_query("SELECT * FROM $tableName");
//==== PUT DATA INTO ARRAY
$array = array();
while ($row = mysql_fetch_row($result)) {
$array[] = $row;
}
//==== ECHO AS JSON
echo json_encode($array);