Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying data from table in an Access database.

Status
Not open for further replies.

bigdavidt

Programmer
Feb 12, 2004
52
US
I want to set up an Access database for a club I belong to. I would like to be able to get information from these tables to display on the club's web site. I have opened the Data Sources Shortcut tool in the Control Panel's Administrative Tools section, clicked on the System DSN tab, and added the Microsoft Access Driver. As things stand now, I can run PHP code in the folder c:\Inetpub\ or any subfolders I create in
I have created a subfolder for my club that holds the Access database. So far there is only one table (with a different name from that of the database) into which I have entered several records. I have also created a PHP test page intended to extract data from this table, but so far I have not succeeded in making it work correctly. Instead I get messages like:

Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Invalid string or buffer length, SQL state S1090 in SQLConnect in c:\Inetpub\ on line 5
Connection Failed:

Apparently I do not have my syntax set up correctly. Any pointers or examples would be appreciated. (I would like to use Access because it is a tool that end users are comfortable with. That way updates could be made to the web site's content without me having to oversee things as closely.)

Have a good one.
 
i am not an expert on odbc but i think you need something more like:
Code:
$cfg_dsn = "
DRIVER=Microsoft Access Driver (*.mdb);
DBQ=c:/inetpub/[URL unfurl="true"]wwwroot/myfiles/wiclub3490/wiclub3490.mdb;[/URL]
";
$cfg_dsn_login = "";
$cfg_dsn_mdp = "";

$conn = odbc_connect($cfg_dsn,$cfg_dsn_login,$cfg_dsn_mdp); 
//the above is taken from user comments on php.net

if (!$conn):
  exit("Connection failed: ". $conn);
endif;
$sql='SELECT criteria, goal, actual, achieved FROM distinguished';

the alternative is to set up a system DSN in the ODBC Administrator.
 
You have to have you query setup with brackets...something like this
Code:
$sql='SELECT criteria, goal, actual, achieved FROM [distinguished]';
I've never done a specific search like you have with criteria, goal, actual. I've always done the star so I'm not sure if you have to put brackets around those fields too. But it took me awhile when I was doing it and brackets are the trick. You have to put them around all your talbe names and field names. So I hope that helps and post back if it didn't do anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top