Forums

This topic is locked

Phakt --- PHP and the problems with ODBC

Posted 10 May 2001 07:12:29
1
has voted
10 May 2001 07:12:29 shawn conrad posted:
Using the new server behaviors and the ability to connect my access.mdb with php, has been well, a long and grueling fight.
See, the initial connection will go as planned through the ADODB and ODBC, but when you preview it live: PROBLEMS!
I have not found the proper documentation that shows connection using the PHakt model and the ADODB scripting. I'm sure it's a problem with variables and my lack of knowledge in this area, but has anyone sucessfully connected a access database with php using UltraDev?, and how?
--would be nice if PHakt came out with a tut for this model--
------------


<<skeebo>>

Replies

Replied 11 May 2001 11:40:24
11 May 2001 11:40:24 vu the anh replied:
Hello, I have a same problem I and I try by delete MM_host..., MM_username and MM_password in connections/yourconnection_file.php
That solve your problem

Hope this hlep,
TheAnh.UDesign

Replied 13 May 2001 03:13:30
13 May 2001 03:13:30 shawn conrad replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hello, I have a same problem I and I try by delete MM_host..., MM_username and MM_password in connections/yourconnection_file.php
That solve your problem

Hope this hlep,
TheAnh.UDesign


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
...................
Well, I still get an error. And this is the specific...
Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\php\adodb\adodb-odbc.inc.php on line 64
.......................
Not sure what this has to do with, the Database type is Access, and the appropriate driver is chosen...
-sc

&lt;&lt;skeebo&gt;&gt;
Replied 13 May 2001 14:40:32
13 May 2001 14:40:32 vu the anh replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hello, I have a same problem I and I try by delete MM_host..., MM_username and MM_password in connections/yourconnection_file.php
That solve your problem

Hope this hlep,
TheAnh.UDesign


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
...................
Well, I still get an error. And this is the specific...
Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\php\adodb\adodb-odbc.inc.php on line 64
.......................
Not sure what this has to do with, the Database type is Access, and the appropriate driver is chosen...
-sc

&lt;&lt;skeebo&gt;&gt;
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

1.Make sure you don't delete MM_DataName or MM_DNS
2.Make sure you already add your mdb file in ODBC - control panel
3. Check your DNS same correctly
Hope this help,
TheAnh.UDesign
PS. If that don't solve your problem, tell me, I send you my way, step by step



Replied 14 May 2001 02:09:32
14 May 2001 02:09:32 shawn conrad replied:
..............

1.Make sure you don't delete MM_DataName or MM_DNS
2.Make sure you already add your mdb file in ODBC - control panel
3. Check your DNS same correctly
Hope this help,
TheAnh.UDesign
PS. If that don't solve your problem, tell me, I send you my way, step by step
..............

Well, it's seems the connection error is still present.
--------
1. I put database in the root folder of site.
2. connect through ODBC make connection as system dns, database name, location.
3. connect with PHakts pop up PHP server behavior.
4. URL &gt;jdbcdbc:dbJobs
5. USR NAME&gt; `NONE`
6. PASS&gt; `NONE`
7. DB TYPE&gt; ODBC
8. HOST&gt; LOCALHOST ( SERVER THROUGH PERSONAL WEB SERVER FOR NOW)
9. TEST CONNECTION&gt; WORKS!
10.ADD THE DETAILS FROM THE RECORDSETS
11. PREVIEW OR VIEW FROM BROWSER&gt; CRASH!
..................................
I would truly love your set up guidelines.
This is crazy, I have set up asp and no problem. I would like to use php.
Thank You,
-sc




&lt;&lt;skeebo&gt;&gt;
Replied 14 May 2001 02:43:55
14 May 2001 02:43:55 shawn conrad replied:
..............

1.Make sure you don't delete MM_DataName or MM_DNS
2.Make sure you already add your mdb file in ODBC - control panel
3. Check your DNS same correctly
Hope this help,
TheAnh.UDesign
PS. If that don't solve your problem, tell me, I send you my way, step by step
..............

Well, it's seems the connection error is still present.
--------
1. I put database in the root folder of site.
2. connect through ODBC make connection as system dns, database name, location.
3. connect with PHakts pop up PHP server behavior.
4. URL &gt;jdbcdbc:dbJobs
5. USR NAME&gt; `NONE`
6. PASS&gt; `NONE`
7. DB TYPE&gt; ODBC
8. HOST&gt; LOCALHOST ( SERVER THROUGH PERSONAL WEB SERVER FOR NOW)
9. TEST CONNECTION&gt; WORKS!
10.ADD THE DETAILS FROM THE RECORDSETS
11. PREVIEW OR VIEW FROM BROWSER&gt; CRASH!
..................................
I would truly love your set up guidelines.
This is crazy, I have set up asp and no problem. I would like to use php.
Thank You,
-sc




&lt;&lt;skeebo&gt;&gt;
Replied 14 May 2001 05:35:37
14 May 2001 05:35:37 shawn conrad replied:
NOW THIS IS THE LAST ERROR (I MANAGED TO CORRECT THE PREVIOUS ONES)
----------------------
Fatal error: Call to undefined function: adodb() in C:\Inetpub\wwwroot\php\adodb\adodb.inc.php on line 28
----------------------
THIS IS LINE 28:

/**
* SET THE VALUE BELOW TO THE DIRECTORY WHERE THIS FILE RESIDES
* ADODB_RootPath has been renamed ADODB_DIR
*/
if (!isset($ADODB_DIR))
$ADODB_DIR = adodb(__FILE__);
---------------------------
$ADODB_DIR = adodb(__FILE__); // = TO THE DIRECTORY IN WHICH ADODB.INC.PHP RESIDES.

This error refers to the function not being defined, but it seems so in the code (as seen above) and the path to the Adodb directory is set, i tried different variables.
So, is the code faulty or am I? ..don't answer that!
-----------------------
Seriously, anyone who has set this up succesfully, please drop me a line, I really am interested in solving this so I can implement Access with PHP.

&lt;&lt;skeebo&gt;&gt;
Replied 14 May 2001 14:20:39
14 May 2001 14:20:39 vu the anh replied:
download ADODB 1.1 now, you won't change anything to run it,

and try another way to connect Access file, reat ADODB tutorial file to learn about it

finally, you should download apache to run php4, I thinks PWS is good but apache is better
Hope that help

Hope this help,

Replied 16 May 2001 09:21:48
16 May 2001 09:21:48 Tim Green replied:
Skeebo,
Please read my latest entry on the comments page of the PHAkT ODBC FAQ at this site.
Replied 16 May 2001 14:43:48
16 May 2001 14:43:48 shawn conrad replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Skeebo,
Please read my latest entry on the comments page of the PHAkT ODBC FAQ at this site.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
..............
Well, I am putting all my folders in the 'wwwroot' folder so I can call my browser (ex: localhost/ 'foldername')
amd test the site .
The 'php' is just the 'test' folder name that resides in the wwwroot folder not the actual php folder--I'm not sure if we got our wires crossed?
You mention that the adodb folder doesn't go in the php folder. where would this folder be stored on the server? in the scripts folder? It seems that the adodb drivers have to reside in the same folder that you are hosting that particular site from. Like 'site1' folder would have all the html files, images files, and the adodb folder files.
thanks,
--sc

&lt;&lt;skeebo&gt;&gt;
Replied 16 May 2001 16:26:33
16 May 2001 16:26:33 Tim Green replied:
Yes, we have our wires crossed.

The adodb folder should be in your website root. Nowhere else.

As for the rest of what I said, I would definitely change your include_path in php.ini back to it's default. You should only change this when you are adding libraries like PEAR. That modification isn't needed to run ADODB, and could be detrimental.

I would suggest, if you continue to have further problems that you check out php.weblogs.com/ADODB to see if anyone else has been having similar problems.
Replied 17 May 2001 19:46:40
17 May 2001 19:46:40 just me replied:
The ADODB connection is not working because of a syntax error, in adodb-maccess.inc.php (or something like that).

You have to use an ODBC connection to connect to MS Access. In the ADODB access file, the string connection is written as

odbc_connect($username, $password, $host);

That is incorrect. The correct syntax, for an ODBC connection, is

odbc_connect ($DSN_NAME,$username, $password);

Once you change that line, you should be able connect to Access with no problems.

-Good luck !

Just...me!

Replied 17 May 2001 22:29:36
17 May 2001 22:29:36 shawn conrad replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
The ADODB connection is not working because of a syntax error, in adodb-maccess.inc.php (or something like that).

You have to use an ODBC connection to connect to MS Access. In the ADODB access file, the string connection is written as

odbc_connect($username, $password, $host);

That is incorrect. The correct syntax, for an ODBC connection, is

odbc_connect ($DSN_NAME,$username, $password);

Once you change that line, you should be able connect to Access with no problems.

-Good luck !

Just...me!


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
.........
Yes, it was brought to my attention in the new tutorial that recently posted here, about the error in the code. I have connected with this adjustment, and the on;y problem is the include statement for the Connections folder can only be found by usind the absolute path instead of relative. strange but when I change it to read include_"(Connections\Compass.php)" instead of the default (./Connections/Compass.php),
it works ...
thanks,
--sc

&lt;&lt;skeebo&gt;&gt;
Replied 12 Dec 2001 16:29:10
12 Dec 2001 16:29:10 Adam Toohey replied:
Hi, I am having the same problems as skeebo. Only I can't seem to get it to work. I have tried everything <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle> This the error I am getting after turning debug to true
Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in c:\inetpub\wwwroot\phptest\adodb\adodb-odbc.inc.php on line 67

Warning: Supplied argument is not a valid ODBC-Link resource in c:\inetpub\wwwroot\phptest\adodb\adodb-odbc.inc.php on line 40
DirectingYou2:

--------------------------------------------------------------------------------
(access): SELECT * FROM Business
--------------------------------------------------------------------------------

Warning: Supplied argument is not a valid ODBC-Link resource in c:\inetpub\wwwroot\phptest\adodb\adodb-odbc.inc.php on line 236

Warning: Supplied argument is not a valid ODBC-Link resource in c:\inetpub\wwwroot\phptest\adodb\adodb-odbc.inc.php on line 45

Why does it write so many files, how many need to be there to work? I am so confused, please could someone help me configure php with access and IIS. I noticed that when I am defining a connection and press test it says connection succussful, but this is only for the dsn, it is not connecting to the database because whatever I put there it still says con successfull. As soon as I do something with the dsn it then gives this error:
Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in c:\inetpub\wwwroot\phptest\adodb\adodb-odbc.inc.php on line 67
When I correct the dsn I get no error until I create a recordset and try to veiw in my browser. When I press the test button in the recordset I do get a connection to the database and I am shown all the data, but when viewing in browser the error above. This is really confusing. I am sure it is something so simple, only I need someone to tell me how. Even if someone who has got it working could send me the posts I will work it out. Please someone help. <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>

Thanks in advance,

Adam Toohey

Replied 14 Dec 2001 00:21:28
14 Dec 2001 00:21:28 David Fee replied:
When setting up the connections, what is supposed to be in the "HOST" box? I currently have the IP of this NT box, but I'm getting the same problem as everyone else in this message:
Call to undefined function: odbc_pconnect() in /var/www/html/arcdslproviders2/adodb/adodb-odbc.inc.php on line 67

Do I have to have PWS running on my NT box for Access97 to talk to the apache server?

Replied 14 Dec 2001 11:15:08
14 Dec 2001 11:15:08 Tim Green replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Why does it write so many files, how many need to be there to work? I am so confused, please could someone help me configure php with access and IIS. I noticed that when I am defining a connection and press test it says connection succussful, but this is only for the dsn, it is not connecting to the database because whatever I put there it still says con successfull. As soon as I do something with the dsn it then gives this error:
Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in c:\inetpub\wwwroot\phptest\adodb\adodb-odbc.inc.php on line 67
When I correct the dsn I get no error until I create a recordset and try to veiw in my browser. When I press the test button in the recordset I do get a connection to the database and I am shown all the data, but when viewing in browser the error above. This is really confusing. I am sure it is something so simple, only I need someone to tell me how. Even if someone who has got it working could send me the posts I will work it out. Please someone help.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

So many files are written so that ADODB can be database independant, and so that your scripts are too.

Configuring PHP with IIS and Access? There are a number of tutorials on the web for this. However, the simplest way to configure PHP with IIS is to use the PHP .msi installer available at www.php.net, failing that, download the PHP zip file <b>and read the readme.txt which gives full details of how to configure IIS</b>

Next point. DSNs are only used for design time connections. At run time you have to actually upload an Access database to the webserver. There is a tutorial on how to use Access with PWS on this very website. Whilst it is a little out of date (the errors the tutorial mentions no longer exist, so therefore the fixes are no longer required) everything else about that tutorial applies. To work with PHP/IIS/Access use the same tutorial, the procedure is essentially the same.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in c:\inetpub\wwwroot\phptest\adodb\adodb-odbc.inc.php on line 6
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

This problem occurs because PHP cannot find your database, or it hasn't been uploaded to your webspace. The fact that you can create a recordset at design time with no problem proves this, so it points to an issue with your configuration of the run-time connection. The tutorial mentioned above (it's at www.udzone.com/showDetail.asp?TypeId=2&NewsId=662) details all of that. If you wish to actually write information to this database, remember to also ensure that the permissions on the database are set to 0755 (or 0777 if that doesn't work).


Hope this helps



Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 14 Dec 2001 15:30:24
14 Dec 2001 15:30:24 Adam Toohey replied:
OK, I have stumbled across the answer for me, I hope it is the answer for anyone else with the same error as me.
I normally design in ASP, where asp works of the dsn, it can be called whatever name you want. I have just found out by accident that in PHP when you name the dsn it needs to be the same name as the database. This must be because of what Tim has said about php using the dsn only in design time. However, it works now, there is nothing in the files to edit like I thought there must be because of the error on line 67.

This has caused me alot of frustration and hours of looking for a fix, so I hope this will help with someone elses frustration. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Thanks,

Adam Toohey

Replied 14 Dec 2001 16:14:23
14 Dec 2001 16:14:23 Tim Green replied:
Again, this solution is detailed in the Tutorial that I pointed you too at the link in my last post (www.udzone.com/showDetail.asp?TypeId=2&NewsId=662)

Glad to see you are now up and running.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 14 Dec 2001 16:19:39
14 Dec 2001 16:19:39 Adam Toohey replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Again, this solution is detailed in the Tutorial that I pointed you too at the link in my last post (www.udzone.com/showDetail.asp?TypeId=2&NewsId=662)

Glad to see you are now up and running.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Actually Tim, without being a smart ass, it says how to set up a dsn, but doesn't say that your dsn must be the same name as your database, otherwise I wouldn't have had any problems at all. I followed that tutorial to a tee.

Adam Toohey

Replied 14 Dec 2001 16:29:13
14 Dec 2001 16:29:13 Tim Green replied:
You're not a smart ass at all Adam. As it says in the Tutorial:-

"Here are the settings I have used :
Connection Name: connCompass
URL: jdbc: odbc:Compass - Compass is the name of the DSN created in Step 1.
User Name: - Left blank, if you configured a username for your DSN, enter it here
Password: - Left blank, if you configured a password for your DSN, enter it here

DB Type: Access
Host: Localhost
<b>Database name: Compass - Again, the name of the DSN created in Step 1</b>
User Name: - Left blank, if you configured a username for your DSN, enter it here
Password: - Left blank, if you configured a password for your DSN, enter it here "

So you did miss something, but appreciate it wasn't shouting out "Here I am".

None-the-less, the solution was there.


Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Edited by - rawveg on 14 Dec 2001 16:29:59

Reply to this topic