title: Microsoft Access from php with odbc Error : (07002)
body: <p>I'm trying to run my first php script that is connecting to my MS Access <code>.accdb</code> database.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
  $dbName = "G:/xampp/htdocs/1.accdb"; 
  $nazwa_produktu = (string)$_POST["nazwa_produktu"];
  $cena = (int)$_POST["cena"];
  $ilosc = (int)$_POST["ilosc"];
  $kategoria = (string)$_POST["kategoria"];
  if (!file_exists($dbName)) {
  die("Access database file not found !");
  }
  $conn = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=$dbName; Uid=; Pwd=;");
  $sql = "INSERT INTO [produkty] (nazwa_produktu, cena, ilosc, kategoria) VALUES ($nazwa_produktu, $cena, $ilosc, $kategoria)";
  if($conn-&gt;query($sql))
      {
         echo 'success';
      }else{
  
             $db_err = $conn-&gt;errorInfo();
             echo 'Error : ('. $db_err[0] .') -- ' . $db_err[2];
      }
  </code></pre>
  
  <p>I'm still getting:</p>
  
  <blockquote>
    <p>Error : (07002) -- [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2. (SQLExecute[-3010] at ext\pdo_odbc\odbc_stmt.c:258)</p>
  </blockquote>
  
  <p>Probably it has something to do with <code>Uid</code> and <code>Pwd</code> in <code>$conn</code> but I really have zero idea what can I do more, because when I try run this without this parameters there's still something wrong. </p>