Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\xampp\htdocs\xampp\display.php on line 5
Connection Failed:

php is working fine, ran other simple php scripts...
but this is the error when i connect to a ms access db

<html>
<body>

<?php
$conn=odbc_connect("DB",'','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
if (!$rs)
  {exit("Error in SQL");}
echo "<table><tr>";
echo "<th>IP</th>";
echo "<th>MAC</th></tr>";
while (odbc_fetch_row($rs))
{
  $name=odbc_result($rs,"ip");
  $macname=odbc_result($rs,"mac");
  echo "<tr><td>$name</td>";
  echo "<td>$macname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>

</body>
</html>

the dsn exists and i have selected a db which has the table clients_online and other fields such as ip and mac exist

Are you sure it is a system dsn and not a user dsn? You must you the system tab in ODBC in the Administrative Tools to set up a system dsn.

HTH

oh thanks, i changed it to a system dsn now...
but i get this error msg


Warning: odbc_connect() [function.odbc-connect]: SQL error: Failed to fetch error message, SQL state HY000 in SQLConnect in C:\xampp\htdocs\xampp\display.php on line 5
Connection Failed:

program being this

<html>
<body>

<?php
$conn=odbc_connect('data','','');
if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM clients_online";
$rs=odbc_exec($conn,$sql);
if (!$rs)
  {exit("Error in SQL");}
echo "<table><tr>";
echo "<th>ip</th>";
echo "<th>mac</th></tr>";
while (odbc_fetch_row($rs))
{
  $compname=odbc_result($rs,"ip");
  $conname=odbc_result($rs,"mac");
  echo "<tr><td>$compname</td>";
  echo "<td>$conname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>

</body>
</html>

Are you sure it is a system dsn and not a user dsn? You must you the system tab in ODBC in the Administrative Tools to set up a system dsn.

HTH

I hear that the pblm is solved.
To others:
Sometimes if the MS-Access file is ".accdb" it wont work!
Pls ensure that it is ".mdb".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.