title: Error in connecting MS-Access database to PHP Server DSN-less
body: <p>I am new to PHP as well as new to Ms-access database. I am trying to connect php server to ms access database dsnless as i have to give this to my friend.  My both php file and ms database file are in same directory and they both are going to stay on localhost only. I am not able to understand the error. </p>
  
  <p>I have 64 bit wamp version 2.4/Apache Version :2.4.4/PHP Version :5.4.16/ 64 bit windows 7
  Also i have installed Microsoft Access Database Engine 2010 Redistributable from official site.  </p>
  
  <p>Here is my php code</p>
  
  <pre><code>&lt;?php
  echo (8 * PHP_INT_SIZE) . "-bit&lt;br/&gt;";
  $user = "";
  $password = "";
  $mdbFilename= "C:\wamp\www\test\testdb.accdb";
  
  $conn=$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $user, $password);              ////&lt;----line 10
  
  if (!$conn) {
    exit("Connection Failed: " . $conn);
  }
  
  $sql="SELECT * FROM testdb";
  $rs=odbc_exec($conn,$sql);
  if (!$rs) {
    exit("Error in SQL");
  }
  
  while (odbc_fetch_row($rs))
  {
      $json_output[] = odbc_result($rs, "test");
      print(json_encode($json_output));
  
  }
  odbc_close($conn);
  ?&gt;  
  </code></pre>
  
  <p>Here is my error</p>
  
  <pre><code>Warning: odbc_connect(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Not a valid file name., SQL state S1000 in SQLConnect in C:\wamp\www\test\working.php on line 10
  </code></pre>