我運行這個PDO查詢在PHP中:PHP PDO SELECT查詢不顯示結果
$stmt = $pdo_conn->prepare("SELECT * from contacts where email = :email ");
$stmt->execute(array(':email' => $from));
$contact = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($contact) > 0) {
echo $contact["email"];
}
,但它不是附和從聯繫人表中的電子郵件列
我知道有挑釁的值有作爲如果我確實迴應「是」;在if語句裏面顯示
我在這裏做了什麼錯?
var_dump($ contact);顯示
array(1) { [0]=> array(22) { ["sequence"]=> string(3) "266" ["newsletter"]=> string(3) "yes" ["company_sequence"]=> string(3) "278" ["title"]=> string(2) "Mr" ["forename"]=> string(7) "Forename" ["surname"]=> string(4) "Surname" ["email"]=> string(22) "[email protected]" ["password"]=> string(32) "**********" ["phone"]=> string(0) "" ["mobile"]=> string(11) "00000000000" ["notes"]=> string(0) "" ["contactstatus"]=> string(0) "" ["logintries"]=> string(1) "0" ["dob"]=> string(10) "0000-00-00" ["receive_allticketupdates"]=> string(3) "yes" ["receive_accountsemails"]=> string(3) "yes" ["can_edit_contacts"]=> string(3) "yes" ["view_all_tickets"]=> string(3) "yes" ["receive_orderemails"]=> string(0) "" ["can_login_online"]=> string(3) "yes" ["last_satisfaction_survey_received"]=> string(10) "0000-00-00" ["receive_domainemails"]=> string(0) "" } }
嘗試在':: fetchAll()'之後運行'var_dump($ contact);'。這將幫助我們看到問題的可能性。 – Sam
什麼是'var_dump($ contact)'? –
檢查我的更新 – user2710234