我正在尝试从mysql输出数据,这是一件非常简单且基本的事情,但是尽管数据库包含数据,但输出为空
require 'dbHandler.inc.php';
$city = mysqli_real_escape_string($conn, $_POST['cityName']);
$rowReturned = array();
print_r($_POST);
$sqlText = "SELECT * FROM batdongsan WHERE city =? ";
echo $sqlText;
echo $city;
if($sqlStatement = mysqli_prepare($conn, $sqlText)) {
mysqli_stmt_bind_param($sqlStatement, "s", $city);
mysqli_stmt_execute($sqlStatement);
$result = mysqli_stmt_get_result($sqlStatement);
while($row = mysqli_fetch_assoc($result)){
echo "Tran Duy Hung";
}
mysqli_stmt_close($sqlStatement);
mysqli_close($conn);
输出在这里
successfully connect to the db
Array ( [cityName] => Hà Nội [address] => [minPrice] => [maxPrice] => [searchSubmit] => )
SELECT * FROM batdongsan WHERE city =? Hà Nội
答案 0 :(得分:0)
此后。...
require 'dbHandler.inc.php';
将其放在您的mysqli_real_connect()或mysqli_connect()调用之后...
@mysqli_query ( $conn, "SET NAMES 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';");