$str. = $sep . $key . "='" . $val . "'"; 报错:syntax error, unexpected '='
function update($table, $array, $where = null) { $link = mysqli_connect ( DB_HOST, DB_USER, DB_PWD ) or die ( "数据库连接失败Error:" . mysql_errno () . ":" . mysql_error () ); mysqli_set_charset ( $link, DB_CHARSET ); mysqli_select_db ( $link, DB_DBNAME ) or die ( "指定数据库打开失败" ); foreach ( $array as $key => $val ) { if ($str == null) { $sep = ""; } else { $sep = ","; } $str. = $sep . $key . "='" . $val . "'"; } $sql = "update{$table} set {$str}" . ($where == null ? null : "where" . $where); mysqli_query ($link, $sql ); return mysqli_affected_rows ($link); }
老师,您好!这行代码:$str. = $sep . $key . "='" . $val . "'"; 报错:syntax error, unexpected '=' )。找了半天没有找到原因。是因为$str后面这个“.”的原因吗?请老师指点