0

Over the past month I have been working on a certificate generation system and one part I have still yet to get working is the part that probably is one of the easier parts. All I need to do is check the email that someone enters against the email of the one in the database, and if that email matches I need to print the first name. I have been reading the PHP manual and looking at other's codes with similar problems and how they fixed it but I cannot seem to get it to work. Is there anything obvious that I am doing wrong or missing that would fix this code?

<?php
$email = $_GET['email'];
$db = new PDO('mysql:host=localhost;dbname=petrzilk_cert14;charset=utf8', 'petrzilk_dbAdmin', '****************'); // Connecting to Database
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
    $query = $db->prepare('SELECT fname, lname, email, Date_Reg, Date_Exp FROM User_Data WHERE email = :email');
    $query->bindValue(':email', $email);
    //$cert = $query->fetchObject(string, 'fname');     First Attempt FAILED
    //$name = $cert['fname'];     First Attempt FAILED
    $result = $query->fetch(PDO::FETCH_OBJ); //From what I found in the manuals online
    print $result->FNAME; //This Does not Display which is what I want to display
    print $email . " Hello!"; //Error checking to make sure the GET works up top. THIS DISPLAYS

?>
2
Contributors
2
Replies
10
Views
3 Years
Discussion Span
Last Post by toxicandy
0

Don't you need to execute the prepared statement?

$query->bindValue(':email', $email);
$query->execute();
$result = $query->fetch(PDO::FETCH_OBJ);
0

I knew I was missing something obvious but even when I executed it still fails to print the First name that is stored with the email. Do you know why this would be?

EDIT: Solved, I had caps FNAME it wasn't a match to fname

Edited by toxicandy

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.