Problem checking Condition [PHP]

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by andylpsx, May 5, 2014.

  1. andylpsx

    andylpsx New Member

    Messages:
    29
    Likes Received:
    1
    Trophy Points:
    3
    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:
    <?php
    $email 
    $_GET['email'];
    $db = new PDO('mysql:host=localhost;dbname=petrzilk_cert14;charset=utf8''petrzilk_dbAdmin''****************'); // Connecting to Database
        
    $db->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
        
    $db->setAttribute(PDO::ATTR_EMULATE_PREPARESfalse);
        
    $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. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    Don't you have to execute the query?
     
    • Like Like x 1
  3. andylpsx

    andylpsx New Member

    Messages:
    29
    Likes Received:
    1
    Trophy Points:
    3
    Do I just have to add the $query->execute(); because I tried that and also executing with a parameter to be passed and changing :email to ? but both still will not output a working response.

    EDIT: I got it working, just had fname in caps which broke it. Thank you for your help!
     
    Last edited: May 5, 2014

Share This Page