我已经将站点从PHP 5.6升级到7.2,并且将代码从mysql切换到了mysqli,不幸的是mysql_result函数已从7.2中删除,因此在这里搜索后我发现了一个替代品,但不幸的是它不起作用。升级之前,我的表已填充,但升级之后,该表为空?!
这是升级之前的代码:
if (isset($_POST['submit'])){
$sql = "SELECT id FROM users
WHERE user='{$_POST['user']}'
AND pass='{$_POST['passwd']}'";
$result = mysql_query($sql);
if (mysql_num_rows($result) == 0){
header("Location: index.php?badlogin=");
exit;
}
$_SESSION['sess_id_tid'] = mysql_result($result, 0);
$_SESSION['sess_user_tid'] = $_POST['user'];
header("Location: tid.php");
exit;
}
这是我升级到7.2后更改代码的方式:
if (isset($_POST['submit'])){
$sql = "SELECT id FROM users WHERE user='{$_POST['user']}' AND pass='{$_POST['passwd']}'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) == 0){
header("Location: index.php?badlogin=");
exit;
}
function mysqli_result($res,$row=0,$col=0){
$numrows = mysqli_num_rows($res);
if ($numrows && $row <= ($numrows-1) && $row >=0){
mysqli_data_seek($res,$row);
$resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res);
if (isset($resrow[$col])){
return $resrow[$col];
}
}
return false;
}
$_SESSION['sess_id_tid'] = mysqli_result($result, 0, 0);
$_SESSION['sess_user_tid'] = $_POST['user'];
header("Location: tid.php");
exit;
}
我想念什么?
更新: 谢谢@Phil和@Madhuri Patel,
以下是我面临的问题的图片:
答案 0 :(得分:0)
mysql_query返回一个mysqli_result对象。从那里,您可以获得想要的价值。
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"actionGroupName": {
"type": "string",
"defaultValue": "newActionGroup",
"metadata": {
"description": "Unique name (within the Resource Group) for the Action group."
}
},
"actionGroupShortName": {
"type": "string",
"defaultValue": "newActionGroup",
"metadata": {
"description": "Short name (maximum 12 characters) for the Action group."
}
},
"emailReceiverName": {
"type": "array",
"metadata": {
"description": "email receiver service Name."
}
},
"emailReceiverAddress": {
"type": "array",
"metadata": {
"description": "email receiver address."
}
}
},
"variables": {
"customemailReceiverName": "[array(parameters('emailReceiverName'))]",
"customemailReceiverAddress": "[parameters('emailReceiverAddress')]"
},
"resources": [
{
"type": "Microsoft.Insights/actionGroups",
"name": "[parameters('actionGroupName')]",
"apiVersion": "2018-03-01",
"location": "Global",
"properties": {
"groupShortName": "[parameters('actionGroupShortName')]",
"copy": [
{
"name": "counts",
"count": "[length(parameters('emailReceiverName'))]",
"input": {
"emailReceivers": [
{
"name": "[parameters('emailReceiverName')[copyIndex('counts')]",
"emailAddress": "[parameters('emailReceiverAddress')[copyIndex('counts')]]"
}
]
}
}
]
}
}
] }