我想将PDO代码转换为mysqli并遇到一些问题。我在这方面还很陌生,我真的不完全了解PDO。
$query = "INSERT INTO gender(gender) VALUES (:gender)";
$statement = $conn->prepare($query);
$statement->execute(array('gender' => $_POST["gender"])
);
$count = $statement->rowCount();
我到现在为止。
$statement = $db->prepare ($query);;
$statement = array('gender' => $_POST["gender"]);
$count=mysqli_num_rows($query);
$statement = mysqli_fetch_array ($query);
尝试此版本:
$query = "INSERT INTO gender(gender) VALUES (?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("s", $_POST["gender"]);
$stmt->execute();
// fetch result set here
$stmt->close();