Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
anisuzzaman
- Forum Newbie
- Posts: 5
- Joined: Sun Apr 10, 2005 1:41 am
Post
by anisuzzaman »
I already connect to MS access with php. Now please help me....How to insert data to Ms access database using php.
Thanks in advance.
Code below:
Code: Select all
<?php
if (!$conn = new COM("ADODB.Connection"))
exit("Unable to create an ADODB connection<br>");
$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("SCJPTIS_IDB.mdb");
$conn->open($strConn);
$strSQL = "SELECT * FROM PROJECTS ORDER BY [PROJ_ID]";
$rs = $conn->execute($strSQL);
$PROJ_ID = $rs->Fields(0);
$PROJ_NAME = $rs->Fields(1);
echo "Table: Projects";
print "<table align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\">";
print "<tr bgcolor=#FFB164><td>ID</td><td>Name</td></tr>";
while (!$rs->EOF)
{
print "<tr bgcolor=\"#1AFFFF\"><td>$PROJ_ID->value</td>";
print "<td>$PROJ_NAME->value</td></tr>";
$rs->MoveNext();
}
print "</table>";
$rs->Close();
$conn->Close();
$rs = null;
$conn = null;
?>
feyd | Please review how to post code using Code: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
-
ast3r3x
- Forum Commoner
- Posts: 95
- Joined: Thu Aug 19, 2004 8:36 pm
Post
by ast3r3x »
I don't know because I've never done it before, but maybe this write up from
php freaks can help.
-
Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Post
by Chris Corbyn »
Have a read up on the
ODBC functions at php.net...
I did this a while ago... it's not "too" dissimilar to MySQL...

-
anisuzzaman
- Forum Newbie
- Posts: 5
- Joined: Sun Apr 10, 2005 1:41 am
Post
by anisuzzaman »
Here's the code for insert data..... but not working
Code: Select all
<?php
if (!$conn = new COM("ADODB.Connection"))
exit("Unable to create an ADODB connection<br>");
$strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("SCJPTIS_IDB.mdb");
$conn->open($strConn);
$strSQL=odbc_exec($strConn,"insert into PROJECTS(PROJ_ID,PROJ_NAME,PROJ_DESC)VALUES
('$_POST[PROJ_ID]','$_POST[PROJ_NAME]','$_POST[PROJ_DESC]')");
$conn->Close();
?>
feyd | Please review how to post code using Code: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
-
anisuzzaman
- Forum Newbie
- Posts: 5
- Joined: Sun Apr 10, 2005 1:41 am
Post
by anisuzzaman »
I have done it..... adding data to access
Now trying for updating and deleting...
-
anisuzzaman
- Forum Newbie
- Posts: 5
- Joined: Sun Apr 10, 2005 1:41 am
Post
by anisuzzaman »
javascript:emoticon(':lol:')