Re: Database access using ODBC
| From: | (Miles Thompson) | Date: | Tue, 26 Jun 2001 17:55:15 +0000 |
| Subject: | Re: Database access using ODBC | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-9843@lists.php.net to get a copy of this message | ||
Colum,
Did you try it, stripping out all of your error testing code, just doing a simple query, such as a "Select * from tablename"?
You could also try searching the archives of the list for these two names:
Andrew Hill, who works for OpenLink, a company which builds ODBC drivers.
and
Manuel Lemos who has developed what I believe is a fairly decent class of database objects.
My problem is that I have no experience using ODBC within PHP, so I don't have any direct hints except to divide and conquer. In other words, if you are getting a connection, then try a simple query, making certain, by echoing it, that it looks OK. Check the error that's thrown and diagnose from there.
Have you tried odbc_connect? Have you checked all the comments in the online manual against what you're doing? (I know that sounds like hectoring, but I once made a 180 mile round trip service call because I was too stubborn to check a piece of network cable.) :<(
One thing I am certain of, the fix, when you find it, will probably be trivial.
Keep plugging, dividing and conquering - Miles
At 05:52 AM 6/26/01 -0400, chickey@mail1.eircom.net wrote:
Thanks for the reply. When it didn't work, I downloaded and installed the mdac 2.6 and the up to date jet service pack. Still no joy. $DBConn is coming back as integer 1 so that seems ok. I have tested the DSN using MSQuery and it is connecting ok. I have also turned tracing on for the dsn and the trace says that it connects successfully but then nothing else. I am a bit lost after this. Anyone any suggestions? Thanks, Colum Original Message: ----------------- From: milesthompson@ns.sympatico.ca (Miles Thompson) Date: Mon, 25 Jun 2001 18:22:52 -0300 To: chickey@eircom.net, php-db@lists.php.net Subject: Re: [PHP-DB] Database access using ODBC Colum, Did you check out www.php.net/odbc_Exec One of the solutions posted in the comments was to download and install a new ODBC driver from MSFT. Are you getting a valid integer returned to $DBConn? NOt worked with this, but I hope those are helpful suggestions - Miles Thompson At 08:38 AM 6/25/01 -0400, chickey@mail1.eircom.net wrote: Hi, Long time reader, first time poster! I am new to php coming from a generally MS (unfortunately) background (Access, VB, SQLServer) and I am looking to branch out a bit. I have a client who wishes to have an internet front-end to an Access database. I am using php with odbc to access this and (as I am a newbie), I am having problems with the connection. After I do an odbc_pConnect, when I call the odbc_exec, I get the usual error, Warning: Supplied agrument is not a valid ODBC-Link resource. The ODBC DSN is setup as standard (no default login etc). The following code is being used for db access: function DBRetrieve($pSQLStr) { global $DBConn, $DBQryID, $DBQryRows, $DBQryColumns; $DBDsn='PHPTEST'; $DBUser='Admin'; $DBPassword =''; #Open a persistent connection to the database if (!$DBConn = (odbc_pConnect($DBDsn, $DBUser, $DBPassword) or die("Database Execution Error: " . odbc_Error() . " " . odbc_ErrorMsg()))) {echo "\nError connecting to database\n"; return false;} #Send query to database if (!$DBQryID=(odbc_Exec($DBConn, $pSQLStr) or die("Database Execution Error: " . odbc_Error() . " " . odbc_ErrorMsg()))) {echo "\nError executing database request: [ODBC_EXEC]\n"; DBDestroy(); return false;} #Get no of rows in recordset if (!$DBQryRows=(odbc_num_rows($DBQryId) or die("Database Execution Error: " . odbc_Error() . " " . odbc_ErrorMsg()))) {echo "\nError executing database request: [ODBC_NUM_ROWS]\n"; DBDestroy(); return false;} #Get number of fields to display if (!$DBQryColumns=(odbc_num_fields($DBQryId) or die("Database Execution Error: " . odbc_Error() . " " . odbc_ErrorMsg()))) {echo "\nError executing database request: [ODBC_NUM_FIELDS]\n"; DBDestroy(); return false;} return true; } Does this look ok to you more experienced guys? Am I missing something or is there a better way? Thanks. Colum -------------------------------------------------------------------- Mail2Web - Check your email from the web at http://www.mail2web.com/ . -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -------------------------------------------------------------------- Mail2Web - Check your email from the web at http://www.mail2web.com/ . -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net