Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Dec 9th, 2012  |  syntax: PHP  |  size: 0.92 KB  |  hits: 44  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. <body>
  4. <?php
  5. try{
  6.    // Connect
  7.    $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\xampp\\htdocs\\bd\\db\\icr.accdb;Uid=Admin");
  8.         $dbh->exec("set names utf8");
  9.     $sql = "SELECT * FROM Miasta";
  10.                         $myFile = "testFile.txt";
  11. $fh = fopen($myFile, 'w') or die("can't open file");
  12.     foreach ($dbh->query($sql) as $row)
  13.         {
  14. echo $row['Nazwa'] .' - '. $row['IDWojewództwa'] . '<br />';
  15. $stringData = $row['Nazwa'] .' - '. $row['IDWojewództwa'] . '<br />';
  16. fwrite($fh, $stringData);
  17.         }
  18. fclose($fh);
  19.     /*** close the database connection ***/
  20.     $dbh = null;
  21. }
  22. catch(PDOException $e)
  23.     {
  24.     echo $e->getMessage();
  25.     }
  26. ?>
  27. </body>
  28. </html>