title: Error on my PDO Construct - Php
body: <p>It's whining of line 6: <code>Warning: PDO::__construct() expects parameter 2 to be string, array given</code></p>
  
  <p>Along with a line 7 error: </p>
  
  <pre><code>Fatal error: Call to a member function prepare() on a non-object in
  </code></pre>
  
  <p>How do I fix this? I've tested the query and it works fine..</p>
  
  <pre><code>&lt;?php
  
  ## Loop through results from mysql
  try{
      #connection string
          $dbconn = new PDO('mysql:host=localhost;port=3306;dbname=thedb',array(PDO::ATTR_PERSISTENT =&gt; true));
          $q = $dbconn-&gt;prepare("SELECT thecol FROM thetbl");
      #call stored proc
          $q-&gt;execute();
      #get the rows into an array
          $result = $q-&gt;fetchAll();
          foreach($result as $r){
              $xmlUrl = $r['FW_ArtSrcLink'];
              $ConvertToXml = simplexml_load_file($xmlUrl);
              # -&gt; Setup XML
              $newsStory = $ConvertToXml-&gt;channel-&gt;item;
          }   
  
      # -----&gt; Load News Stories
          for($i = 0;$i&lt;sizeof($newsStory); $i++){
  
      # Source of Article Info--&gt;
              $SrcTitle=$newsStory[$i]-&gt;title;
              $SrcLink=$newsStory[$i]-&gt;link;
  
      # Actual News Article Info --&gt;
              $title=$newsStory[$i]-&gt;title;
              $desc=$newsStory[$i]-&gt;description;
  
      # Output Results ------------&gt;      
              echo '&lt;hr&gt;';
              echo '&lt;strong&gt;'.'Title:'.$title.'&lt;/strong&gt;'.'(via: &lt;a href=\''.$SrcLink.'\'&gt;'.$SrcTitle.'&lt;/a&gt;'.'&lt;br /&gt;';
              //echo 'Link:'.$link.'&lt;br /&gt;';
              echo 'Description'.$desc.'&lt;br&gt;';
              echo '&lt;hr&gt;';
          }
  } // try
  
  catch(Exception $e){
  
      $errorStored = $e-&gt;getMessage() . ' on ' .'/errors/fanwire_loop.php';  #where errors are stored
      $pageDateOfError = '/aggregate_looping.php'.date('l jS \of F Y h:i:s A'); #inc the file and date into the file too
      file_put_contents($errorStored,$pageDateOfError, FILE_APPEND | LOCK_EX);
  } // catch
  
  #Load in File
  
  
  /*************************************************
  
  
  
  $xmlUrl ="http://sports.espn.go.com/espn/rss/mlb/news";
  $ConvertToXml = simplexml_load_file($xmlUrl);
  
  
  
  # -&gt; Setup XML
  $newsStory = $ConvertToXml-&gt;channel-&gt;item;
  
  # -----&gt; Load News Stories
  for($i = 0;$i&lt;sizeof($newsStory); $i++){
  
      // Source of Article Info--&gt;
      $SrcTitle=$newsStory[$i]-&gt;title;
      $SrcLink=$newsStory[$i]-&gt;link;
  
      // Actual News Article Info --&gt;
      $title=$newsStory[$i]-&gt;title;
      $desc=$newsStory[$i]-&gt;description;
  
  
      echo '&lt;hr&gt;';
      echo '&lt;strong&gt;'.'Title:'.$title.'&lt;/strong&gt;'.'(via: &lt;a href=\''.$SrcLink.'\'&gt;'.$SrcTitle.'&lt;/a&gt;'.'&lt;br /&gt;';
      //echo 'Link:'.$link.'&lt;br /&gt;';
      echo 'Description'.$desc.'&lt;br&gt;';
      echo '&lt;hr&gt;';
  }
  
  ***********************************************/
  
  ?&gt;
  </code></pre>