Jump to content

how can i connect to ms access by php?  

  1. 1. how can i connect to ms access by php?

    • my code is error
      0
    • wrong connection
      0


Recommended Posts

i have a database in ms access i want to use php to enter data.

i set up my odbc in control panel.

 

here is my code in php

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body>

<?php

$conn=odbc_connect ('yhentry','','');

if ($conn)

{

exit ("Connection Failed" . $conn);

}

 

$sql="Select * from YH Entry";

$rs=odbc_exec($conn,$sql);

 

if (!$rs)

{

exit ("Error in SQL");

}

 

echo "<table><tr>";

echo "<th>Directory Name</th>";

echo "<th>Filename</th>";

 

while (odbc_fetch_row($rs))

{

$directory=odbc_result($rs,"Directory");

$filename=odbc_result ($rs,"Filename");

echo "<tr><td>$directory</td>";

echo "<td>$filename</td></tr>";

}

odbc_close ($conn);

echo "</table>";

 

?>

</body>

</html>

 

and my access is working...

 

pls help me with my code.

 

thanks

???

  • 3 weeks later...

Hmmm using something great as php and combining it with something evil from microsucks what a sin  :P using mySQL or postgresql is easier and better.

 

You're code seems good have you setup the odbc connection correctly in your Administrative Tools.

 

here is a link http://www.w3schools.com/php/php_db_odbc.asp

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.