Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > MS Access & PHP Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-07, 11:09
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
Question MS Access & PHP Question

I need to create a form for users to enter in information. The information they need to enter is:

~ Name
~ Date
~ Miles
~ Activity

In my MS Access database, the name is set up in a table named name analyzer and all of the information needs to be entered into a table named activity_log. I want it to verify that the name is in the name analyer table, but if it's not, send an error message to the user.

Okay so here is my question, can I do this with PHP? I've worked with PHP & MySQL before but never with Access.

If it's possible can someone direct me to a tutorial or something so I can figure out how to do this? I need to have this page done by tomorrow and I'm clueless!

Thanks!
Reply With Quote
  #2 (permalink)  
Old 10-24-07, 07:35
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 337
Php

If you have a server (Microsoft based-I am not sure that ms Access runs at others like Linux etc) running php you can.And that will run via web browser .
You may read this and this .
Reply With Quote
  #3 (permalink)  
Old 10-24-07, 07:39
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 734
You can connect to MSAccess in PHP using ODBC.
See http://uk2.php.net/manual/en/function.odbc-connect.php to get yourself started. You'll need to create a DSN connection string in windows before you can utilise it however.

After that it's pretty much the same as using MySQL in PHP, and you can perform SQL statements as you would any other database.
Reply With Quote
  #4 (permalink)  
Old 10-24-07, 07:41
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 734
When you talk about "verify that the name is in the name analyer table" do you mean that the user is entering some login information and if those login details don't exist then you have to output a message saying such? Or are you talking about some other sort of input and verification?
Reply With Quote
  #5 (permalink)  
Old 10-24-07, 09:41
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
Quote:
Originally Posted by aschk
When you talk about "verify that the name is in the name analyer table" do you mean that the user is entering some login information and if those login details don't exist then you have to output a message saying such? Or are you talking about some other sort of input and verification?

Yes.

Thank you all for your help! I greatly appreciate it!!
Reply With Quote
  #6 (permalink)  
Old 10-24-07, 09:45
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
Okay so I have another stupid question. For the ODBC connection, do I need to set that up on the server this will be located on?
Reply With Quote
  #7 (permalink)  
Old 10-24-07, 10:03
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 337
What version of MS Access do you have.
If you have 2007 for the connection sting look at this else this.
Connectionstrings
Quote:
ODBC DSN-less Connections
DSN less connections don't require creation of system level DSNs
for connecting to databases and provide an alternative to DSNs.
Instead of using a DSN to connect to a database,
the developer specifies the necessary information right in the application.
With a DSN-less connection the developer is free to use connection standards
other than ODBC, such as OLE DB.
DSN-less connections should be used when you do not have access to the server to register DSNs yourself.
For Microsoft Access, the following connection string is used to create DSN-less connections:
Driver={Microsoft Access Driver (*.mdb)}; DBQ=c:\path\to\database.mdb

Last edited by dimis2500 : 10-24-07 at 10:09.
Reply With Quote
  #8 (permalink)  
Old 10-24-07, 10:05
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
Quote:
Originally Posted by dimis2500
What version of MS Access do you have.
If you have 2007 for the connection sting look at this else this

I have 2003.

So do i put this in my code?

Code:
Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;

with my db information of course though..

Last edited by mstng07 : 10-24-07 at 10:08.
Reply With Quote
  #9 (permalink)  
Old 10-24-07, 10:13
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 337
Code:
odbc_connect ( string $dsn, string $user, string $password [, int $cursor_type] )
As I understand at
Code:
$dsn
.
Reply With Quote
  #10 (permalink)  
Old 10-24-07, 10:18
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
I'm just trying to test this...

Code:
<? $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); // Microsoft Access connection string. $conn->Open("Provider=Microsoft,.Jet.OLEDB.4.0; Data Source=F:\\Inetpub\\wwwroot\\EmployeeWellnessProgram\\Copy of HR Employee Wellness Program.mdb"); // SQL statement to build recordset. $users = $conn->Execute("SELECT * FROM [analyzer query]"); // Display all the values in the records set while (!$users->EOF) { $fv = $users->Fields("[Employee ID]"); echo "Value: ".$fv->value."<br>\n"; $users->MoveNext(); } $users->Close(); ?>

and i get these errors...
Warning: (null)(): Invoke() failed: Exception occurred. Source: ADODB.Connection Description: Provider cannot be found. It may not be properly installed. in F:\InetPub\wwwroot\EmployeeWellnessProgram\TestDis play.php on line 5

Warning: (null)(): Invoke() failed: Exception occurred. Source: ADODB.Connection Description: Operation is not allowed when the object is closed. in F:\InetPub\wwwroot\EmployeeWellnessProgram\TestDis play.php on line 8

Fatal error: Call to a member function on a non-object in F:\InetPub\wwwroot\EmployeeWellnessProgram\TestDis play.php on line 13
Reply With Quote
  #11 (permalink)  
Old 10-24-07, 10:28
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 337
Maybe this
Code:
Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;
And I thing that is better not to have spaces the strings like names of files.
Strings.

Last edited by dimis2500 : 10-24-07 at 10:58.
Reply With Quote
  #12 (permalink)  
Old 10-24-07, 11:13
mstng07 mstng07 is offline
Registered User
 
Join Date: Oct 2007
Posts: 27
yeah i know it's better but i didn't create the database. sure as heck would be easier without the spaces because i don't know if i'm doing it right
Reply With Quote
  #13 (permalink)  
Old 10-25-07, 03:39
dimis2500 dimis2500 is offline
Registered User
 
Join Date: Jan 2005
Posts: 337
Spaces

So you can give the database a name without spaces, just rename it.
The script is ok now?
Dimis
Reply With Quote
  #14 (permalink)  
Old 10-25-07, 08:31
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 734
Ah right, you're using COM objects.
This is ONLY available on Windows and relies on the COM being installed.
Don't use COM, use odbc_connect as it's built into PHP by default (in most cases). It's easier to use, because it works pretty much the same way all the mysql_... functions do.
Reply With Quote
  #15 (permalink)  
Old 10-25-07, 08:40
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 734
See http://www.w3schools.com/php/php_db_odbc.asp for some help.

A code example might look like this :
Code:
<html> <body> <?php $dsn_str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\Inetpub\wwwroot\EmployeeWellnessProgram\Copy of HR Employee Wellness Program.mdb;"; // Connect to DSN $conn=odbc_connect($conn_str,'MyDBUser','MyDbPassword'); // If connection failed if (!$conn) {exit("Connection Failed: " . $conn);} // Query string $sql="SELECT * FROM table_name"; // Execute Query $rs=odbc_exec($conn,$sql); // On query fail if (!$rs) {exit("Error in SQL");} // Set up table echo "<table><tr>"; echo "<th>Column1</th>"; echo "<th>Column2</th></tr>"; // Loop recordset while (odbc_fetch_row($rs)) { $col1=odbc_result($rs,"Column1"); $col2=odbc_result($rs,"Column2"); echo "<tr><td>$col1</td>"; echo "<td>$col2</td></tr>"; } // Close connection odbc_close($conn); // Close table echo "</table>"; ?> </body> </html>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On