I am trying to show results from a simple select statement using PDO
<?php  
    // Define and perform the SQL SELECT query
     include('config.inc');
     $user = $_POST['user']; 
     $password = $_POST['password'];
      $sql = "SELECT * FROM usuarios where user = '$user' AND password ='$password'";
      $stm = $db->prepare($sql);
      $stm->execute();
      // here you go:
      $users = $stm->fetchAll();
      foreach ($users as $row) {
           print $row["user"] . "-" . $row["password"] ."<br/>";
      }
    ?>
And the only thing I get is errors like this one:
Undefined index: user in C:\wamp\www\proyect\select.php on line 16
Perhaps is something really simple I might be overlooking in this test, I am working with php 5.3.5.
This is the included file:
  <?php
          $dsn = 'mysql:host=localhost;dbname=carrito';
          $username = 'root';
          $password = 'root';
          try {
               $db = new PDO($dsn, $username, $password);
               $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          }catch (PDOException $e){
               $error_message = $e->getMessage();
               //include('db_error.php');
               echo $error_mesage;
               file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
               exit();
          }
?> 
 
     
     
    
";` to `print_r($row)."
";` to see what column names/values are in your table – Sean Aug 04 '13 at 23:43