473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Using PHP to pull from MS Access DB

I've been trying to create a simple (I hope) PHP application to send
emails to a membership list. I have yet to successfully connect to my
database to pull the names and email addresses. I'm running XP Pro,
PHP Version 4.3.2, Access 2000. I have created an ODBC System DNS
connection to the database file I want to access, And I get this error:

Warning: SQL error: , SQL state 00000 in SQLConnect in connecttodb.php
on line 2
Whoops! Could Not Connect to ODBC Database!

Here is my code:

<?php
$odbc = odbc_connect ('DFWMembershipDB', '', '') or die('Whoops! Could
Not Connect to ODBC Database!');
?>

I'm a total novice at this, so any help you can provide would be really
appreciated.

Chad Lupkes
Seattle, Washington

Nov 22 '05 #1
12 6267
as you've probably noticed, "whoops!" doesn't get you too far. i think if
you output the actual error, you'd probably be able to figure it out by
yourself. as for those here, "whoops!" means jack-squat.

(dfw = dallas/fort worth? just curious)
"chadlupkes" <ch********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
| I've been trying to create a simple (I hope) PHP application to send
| emails to a membership list. I have yet to successfully connect to my
| database to pull the names and email addresses. I'm running XP Pro,
| PHP Version 4.3.2, Access 2000. I have created an ODBC System DNS
| connection to the database file I want to access, And I get this error:
|
| Warning: SQL error: , SQL state 00000 in SQLConnect in connecttodb.php
| on line 2
| Whoops! Could Not Connect to ODBC Database!
|
| Here is my code:
|
| <?php
| $odbc = odbc_connect ('DFWMembershipDB', '', '') or die('Whoops! Could
| Not Connect to ODBC Database!');
| ?>
|
| I'm a total novice at this, so any help you can provide would be really
| appreciated.
|
| Chad Lupkes
| Seattle, Washington
|
Nov 22 '05 #2
steve wrote:
as you've probably noticed, "whoops!" doesn't get you too far. i
think if you output the actual error, you'd probably be able to
figure it out by yourself. as for those here, "whoops!" means
jack-squat.


And "whoops!" isn't a word you want to hear from a sysadmin who's
upgrading a critical system. Especially if followed by "you have
backups of this, right?"

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Nov 22 '05 #3

"Kim André Akerĝ" <ki******@NOSPAMbetadome.com> wrote in message
news:3u*************@individual.net...

| And "whoops!" isn't a word you want to hear from a sysadmin who's
| upgrading a critical system. Especially if followed by "you have
| backups of this, right?"

roflmao
Nov 22 '05 #4
So, saying I'm a total novice didn't make it clear enough, eh?

How do I output the actual error?

(DFW - Democracy for Washington)

Nov 23 '05 #5
novice implies ignorance and not stupidity. while there is nothing wrong
with the former, the latter i find is hard to excuse.

i bet if you were to google "php odbc error help", you'd find your answer.
or if you went to php.net and searched for "odbc error", you'd likewise come
up with odbc_error() and odbc_errormsg()

searching for and finding help is a methodology employed by anyone with a
problem. as we all have them, none are novices. asking for help with novice
questions when the answer(s) are so pervasive, prevelent, and otherwise
readily available is...well...stupid. what's worse is doing so and then
being smug at the same time...eh! but, perhaps i just mis-read your tone in
this media.

(there is no d in w, but thanks for curing my curiosity)
"chadlupkes" <ch********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
| So, saying I'm a total novice didn't make it clear enough, eh?
|
| How do I output the actual error?
|
| (DFW - Democracy for Washington)
|
Nov 23 '05 #6
You mis-read. I was smiling.

I've been looking through the thousands of results from searches like
the ones you recommended, and I've been trying a lot of what I find.
Every step just leads to more and more questions that I can't find
answers to. So, I appreciate the direct help.

I'm trying to create a very simple script that will pull email
addresses from an existing database and export them with message
content to my local smtp server. To do that, I've read that I need to
set up an System DNS to the database file, which I've done according to
all the directions I can find. Now I'm trying to test the connection.

The errors I'm getting are leading me into another maze of search
results, and they all seem to be for people who have a basic
understanding of what is happening. Or the tutorials assume that
everything works just as they describe. So when things don't work, I
ask for help.

Chad

Nov 23 '05 #7
Here's the latest update:

<?php
$connectionstring = odbc_connect("DFWDB", "chad", "dfw");
if (odbc_error())
{
echo odbc_errormsg($connectionstring);
}
odbc_close($connectionstring);
?>

This is what comes out:

Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] The
Microsoft Jet database engine cannot open the file '(unknown)'. It is
already opened exclusively by another user, or you need permission to
view its data., SQL state S1000 in SQLConnect in
C:\Inetpub\wwwroot\politics\DFW\connecttodb.php on line 2

Warning: odbc_errormsg(): supplied argument is not a valid ODBC-Link
resource in C:\Inetpub\wwwroot\politics\DFW\connecttodb.php on line 5

Warning: odbc_close(): supplied argument is not a valid ODBC-Link
resource in C:\Inetpub\wwwroot\politics\DFW\connecttodb.php on line 7

--
This doesn't make sense. I don't have any other connections open to
the database, although I can't get the ODBC logfile to work to check.
I haven't set any restrictions on access, since this is all on my local
machine, although I'm not sure what permissions I need to set. And the
odbc_ functions just seem to fail.

I'm really lost.

Nov 23 '05 #8
ok, smiling one. ;^)

usually, one db error will cascade multiple errors in php since most db
functions rely on a resource provided by another db function. anyway...what
you've got is a failure to connect and yet you continue to try to use other
functions that rely on that connection which in turn throws errors number 2
and 3.

your literal problem is that access (shitty as it is) stores its data in a
file. when php tries to open that db/file, your pc tries to access it as
IUSR_<computer name here>...that is, if you're using IIS (incredibly
insecure server). you must allow read/write permissions for that user on the
directory in which your mdb resides.

btw, you do *NOT* need a dsn to connect to the db, as a standard odbc
connection string in the form of:

"Driver={Microsoft Access Driver
(*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"

will work just fine.

(look at http://www.connectionstrings.com/ for most common connection
strings)
does that explain things to your satisfaction?
| Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] The
| Microsoft Jet database engine cannot open the file '(unknown)'. It is
| already opened exclusively by another user, or you need permission to
| view its data., SQL state S1000 in SQLConnect in
| C:\Inetpub\wwwroot\politics\DFW\connecttodb.php on line 2
|
| Warning: odbc_errormsg(): supplied argument is not a valid ODBC-Link
| resource in C:\Inetpub\wwwroot\politics\DFW\connecttodb.php on line 5
|
| Warning: odbc_close(): supplied argument is not a valid ODBC-Link
| resource in C:\Inetpub\wwwroot\politics\DFW\connecttodb.php on line 7
|
| --
| This doesn't make sense. I don't have any other connections open to
| the database, although I can't get the ODBC logfile to work to check.
| I haven't set any restrictions on access, since this is all on my local
| machine, although I'm not sure what permissions I need to set. And the
| odbc_ functions just seem to fail.
|
| I'm really lost.
|
Nov 23 '05 #9
Well, well. Yes, that did it. And none of the tutorials I had found
mentioned a possible permissions problem, so I hadn't even considered
it. You saved the day.

Now I just have to figure out SQL...

Thanks!!

Chad

Nov 24 '05 #10
Ok, looks like I do have one more question. The page works, but only
when the file is closed. Is it possible to set the permissions such
that I can use the database through the Access interface at the same
time I'm doing SQL queries through the web server?

Chad

Nov 24 '05 #11
that's nothing to do with php or file permissions...you have to open the db
in access and set its options to not open exclusively. check access' help
files for that...too many moons have gone by since i've messed around with
it.

glad you've gotten over your first hurdle.
"chadlupkes" <ch********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
| Ok, looks like I do have one more question. The page works, but only
| when the file is closed. Is it possible to set the permissions such
| that I can use the database through the Access interface at the same
| time I'm doing SQL queries through the web server?
|
| Chad
|
Nov 24 '05 #12
On Wed, 23 Nov 2005 09:23:08 -0600, steve wrote:
your literal problem is that access (shitty as it is) stores its data in a
file.


Steve - it's not *that* bad ;-) - for an average sized application.
I've used it with ColdFusion and PHP on pretty busy sites. The usual
networking gotchas in Access (locking) are avoided as PHP (or CF)
handles/buffers the requests.

Sometimes, the client insists on keeping the DB in its native format
(and maybe swaps the whole file over periodically). It can end up
quicker.

The only real downside I find is the weird Access time/date format.

Adam.
Mar 7 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bob | last post by:
Currently I am using this statement to translate 3 fields in my db thru Visual Basic. I import the data from one table to another then call the IFF statements and the NewDate to translate the...
5
by: Julia Baresch | last post by:
Hi everyone, I haven't found any reference to this problem on this group or in Access 97 help. I hope someone here knows this - probably a simple thing, but not obvious. I designed a query to...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
4
by: Ecohouse | last post by:
I need to be able to access an Outlook folder and read each email and pull data from the email into tables in Access and move the email to another folder. I now about automation but am not sure...
0
by: Kumar | last post by:
Hi Folks, I would like to develop one custom application using asp.net,C#,SQL server for tracking all our company servers. Most of the functionality is similar to HP Systems Insight Manager ...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
1
by: TheDataGuy | last post by:
Using MS ACCESS 2002 Problem - I developed a form, and within that FORM, I added a SEARCH BUTTON, and then I created a SUB-FORM, so when an end user clicks on the FORM it will POP-UP the SUB-FORM,...
5
by: Hollywood | last post by:
Good day dear members of the comp.databases.ms-access newsgroup. Please I need your help on the following. I'm the administrator of an Access 2007 database. I would like my enterprise personnel...
5
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make...
0
by: shwethatj | last post by:
Can anyone please help me..... In Crystal Reports , how to access data using PULL method .. I have got a table in server explorer which has 3 got fields. But i dont know how to access it and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.