SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    634
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Most likely a very simple PDO/mysql question

    As far as I can tell all the semi colons are there. I get no error messages. but print_r($query); get me nothing...don't understand what I got wrong?

    PHP Code:
    <?php
    //a_db my database
    //tab01 my table
    //title one of the rows in my table

    $config ['db']    = array(
    'host'        =>'localhost',
    'username'    =>'root',
    'password'    =>'',
    'dbname'    =>'a_db'
    );
     
    $db = new PDO('mysql:host'.$config['db']['host'].';dbname'.$config['db']['dbname'],$config['db']['username'], $config['db']['password']);
    $query $db->query("SELECT `tab01`.`title` FROM `tab01`");

    print_r($query);
      
    ?>

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,812
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    To start, you are missing the = in your PDO connection string.

    PHP Code:
    $db = new PDO('mysql:host='.$config['db']['host'].';dbname='.$config['db']['dbname'],$config['db']['username'], $config['db']['password']); 
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Guru
    Join Date
    Oct 2010
    Location
    Portland, Or
    Posts
    634
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Cpradio! Thank you, you got it.
    I kept looking and looking but didn't see that at all.
    d


Tags for this Thread

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
  •