By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

Connecting to a Access database using ODBC and no DNS

P: 23
Hi, I'm having problems connecting to a Microsoft Access database. Im using PHP and ODBC but im not using a DNS.

The scripts below give no errors but I they only give me a blank white screen.

Any would be greatly appresiated. Please help.

Script 1
[php]
<HTML>
<HEAD>
<TITLE> Browse the race table </TITLE>
</HEAD>
<BODY>
<?php
$connstr = "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=".realpath("Database/2PointB.mdb").";";
$conn=odbc_connect($connstr,",");
$stmt=odbc_tables($conn);
while( odbc_fetch_row($stmt))
{
$tabletype = odbc_result($stmt,4);
$tablename = odbc_result($stmt,3);
if($tabletype =="TABLE")
{
Print "<a HREF=browserace.php?table=" .$tablename.">" .$tablename ."</a>";
Print "<br>";
{
}
?>
</BODY>
</HTML>[/php]Script 2[php]
<HTML>
<HEAD>
<TITLE> Browse </TITLE>
</HEAD>
<BODY>
<?php
$table=$_GET["table"];
$sql="Select * from $table";
$connstr = "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=".realpath("Database/2PointB.mdb").";";
$conn=odbc_connect($connstrr,",");
$stmt=odbc_exec($conn,$sql);
$nofileds=odbc_num_fields($stmt);
while( odbc_fetch_row($stmt))
{
$i=1;
while ($i<$nofields)
{
Print odbc_result($stmt,$i)."";
$i==;
}
Print "<br>";
}
?>
</BODY>
</HTML>[/php]
Apr 12 '08 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
You don't get an error, because you don't display any errors. Add an error display to each of the odbc_* command like[php]$conn=odbc_connect($connstr,",")
or die ("connect error: ".odbc_error());
$stmt=odbc_tables($conn)
or die ("show table error: ".odbc_error());[/php]and you'll get more information on your problem.

Ronald
Apr 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.