Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php on an access database? 2

Status
Not open for further replies.

svar

Programmer
Aug 12, 2001
349
GR
I'm looking for recommendation on how to:
-install Apache on Windows
-install PHP on Windows
-connect to an Access Database

For Apache and PHP it looks like one may need a C compiler (or probably specifically MS Visual C?)
Is that correct or can one also find a binary or an installer?

Also in the db connect script: I guess something like this will do with HOST=''
Code:
<?php  
include_once 'globaldata.php'; 
$link=odbc_connect(HOST,DATABASE,'','');
if (!$link) {
  exit("Connection Failed: " . $link);
?>
 
You can install binaries of both apache and php for windows. Both are available from their own websites. Or you can install a wamp package.

To connect to access you should look at using pdo with an odbc connector. Do this through a system dsn in control panel from memory

You can use native odbc× as an alternative. You still do so through a system dsn though. You cannot just specify the dB file in the connection function.
 
The route I have taken is to create tables on a MySQL server and then connect them to Microsoft Access via the MySQL ODBC driver. So no data is actually stored in Access. Access is just a GUI frontend to the MySQL tables.
 
Can I get an example of pdo/odbc with php?
 
There's a few in the online manual at PHP.net:






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
How does one check for errors with ODBC akin to
Code:
mysqli_connect(HOST, USER, PASSWORD, DATABASE);
if(NULL !== ($err = mysqli_connect_error())) die($err);
?

E.g.
Code:
include_once 'globaldata.php'; 
$link = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", USER, PASSWORD);

if (odbc_error())
         {
               echo odbc_errormsg($conn);
         }
 
Yup it appears the newest zip file is missing the msi installer. I would try a WAMP installer instead.


It will install all 3 things in one single installer. Apache, MYSQL, PHP

As to the error, you can do it the same way:

Code:
if('' !== odbc_error()) die(odbc_errormsg());





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thanks. Two reasons why I id not use wamp already:
1) I had already installed apache(not sure if this would conflict with the existing Apache I had installed) Would that create a conflict?
2) PHP in wamp seems to be a version old
 
NNot all php versions have windows MSI packages. It generally takes time and the packagers wait for versions to bed in as all libs need recompiling too. Unless you want absolute bleeding edge its fine to go back a few point versions and use the MSI. Particularly if you have dependencies on modules.
 
I did install wamp, then got
Code:
try{ $link = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $username, $password); }
catch(PDOException $e){ echo $e->getMessage(); }
and got
could not find driver

Do I need to install odbc separately? And if so, where do I find this?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top