更新时mysqli_affected_rows()

时间:2017-07-06 01:24:27

标签: php

我在此代码中遇到问题,有人可以帮忙吗?:( 这是我的代码:

$query = "UPDATE subjects SET
              menu_name = '{$menu_name}',
              position = {$position},
              visible = {$visible}
              WHERE id = {$id}";
    $result = mysqli_query($connection, $query);
    if (mysqli_affected_rows() == 1) {
      $message = "The subject was successfully updated.";
    } else {
      $message = "The subject update failed.";
      $message .= "<br>" . mysqli_error();
    }

  } else {
    $message = "There were " . count($errors) . " errors in the form.";
  }

2 个答案:

答案 0 :(得分:0)

mysqli_affected_rows(); 
  

需要连接。指定要使用的MySQL连接

将您的代码更改为

mysqli_affected_rows($connection); 

答案 1 :(得分:0)

$result

在括号中使用 var express = require('express'); var app = express(); app.listen('/tmp/sock'); 变量。