Re: Database access using ODBC
| From: | (Miles Thompson) | Date: | Mon, 25 Jun 2001 21:22:52 +0000 |
| Subject: | Re: Database access using ODBC | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-9814@lists.php.net to get a copy of this message | ||
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