Results 1 to 1 of 1

Thread: help with php pdo mysql

  1. #1
    Join Date
    May 2009
    Location
    Greensboro, GA
    Posts
    163
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default help with php pdo mysql

    What I want to do is run a query based on user input (fname, lname passed from an html program). If I don't find a record, I want to close the database and run a different htm file
    Thanks for any help.

    This is a piece of my code:

    PHP Code:
    <?php
    $fname 
    filter_input(INPUT_POST"fname");
    $lname filter_input(INPUT_POST"lname");

    try    
        {
        
    $connect = new PDO('mysql:host=localhost;dbname=xxxxxx'"xxxxxx""xxxxxx");
        echo 
    'Connected to database<br />';
        
    $connect->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);

        
    $sql "SELECT * FROM contacts WHERE firstname = '$fname' && lastname = '$lname' ";


        
    $connect null;        
        }
                 
    catch(
    PDOException $e)
         {
         echo 
    'ERROR: ' $e->getMessage();
         }
    ?>
    Last edited by mcolton; 06-16-2014 at 04:54 PM. Reason: Format: Php Tags [php][/php]

Similar Threads

  1. Replies: 0
    Last Post: 01-04-2011, 01:17 PM
  2. Replies: 1
    Last Post: 10-20-2010, 06:18 AM
  3. Replies: 1
    Last Post: 12-27-2009, 01:12 AM
  4. Replies: 0
    Last Post: 03-07-2009, 07:27 PM
  5. Upgrading from mySQL 4 to mySQL 5
    By kuau in forum PHP
    Replies: 3
    Last Post: 05-16-2008, 04:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •