Re: ODBC failed

From: Date: Tue, 14 Aug 2001 20:55:47 +0000
Subject: Re: ODBC failed
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11348@lists.php.net to get a copy of this message
You are using "phoneinfo" both as a table name and a datasource name. You *could* do that, but I don't think it's what you're trying for :) Go back to your control panel and see what you named the ODBC you created (datasource name, or DSN). You use that name for the first parameter for your ODBC connection call, like so: $odbc_dsn="my_odbc_dsn"; $odbc_uid="my_db_uid"; $odbc_pwd="my_db_pwd"; $sql="SELECT * FROM my_table"; $connection = odbc_connect ($odbc_dsn, $odbc_uid, $odbc_pwd) or die ("Can not connect to $odbc_dsn."); $resultset = odbc_exec ($connection, $sql) or die ("Can not perform query"); Note that $odbc_uid and $odbc_pwd can be blank (""), providing your database allows access via NT authentication *AND* you specified in your ODBC DSN that you wish to use that type of authentication. Otherwise, use a UID and password, and ensure they're in your ODBC DSN too. Caveat: I don't use MS Access -- I use MSSQL, but I'm pretty sure the principles are the same for the two drivers. On Thu, 26 Jul 2001 22:34:58 -0700 (PDT), yokemk@yahoo.com (Meng Yoke) wrote: >Hi, > >php 405 >IIS 5.0 / W2K >MS Access 2000 > >I had a simple script that will connect to MS Access >DB. I had created the DSN and it was tested ok on the >dos promopt. > >When I tested using the IIS, it failed: > >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\o2.php on line 3 > >Warning: Supplied argument is not a valid ODBC-Link >resource in c:\inetpub\wwwroot\o2.php on line 5 > > >This is my script: > ><? >$cx=odbc_connect ("phoneinfo", "", ""); > >$cur=odbc_exec($cx,"select * from phoneinfo"); >?> > >any help appreciated? > >thanks. > >- yoke > > >===== >======================================= > Yoke Meng Keong > Email : yokemk@yahoo.com > eFax : (253) 669-6578 (US) >======================================= > >__________________________________________________ >Do You Yahoo!? >Get personalized email addresses from Yahoo! Mail >http://personal.mail.yahoo.com/

« previous php.db (#11348) next »