php-db | 2001062
Date: 06/25/01
- Next message: Jorge Alvarez: "Re: [PHP-DB] Interbase Problem"
- Previous message: Adam Lundrigan: "[PHP-DB] Is MySQL in 4.0.6?"
- Next in thread: Miles Thompson: "Re: [PHP-DB] Database access using ODBC"
- Reply: Miles Thompson: "Re: [PHP-DB] Database access using ODBC"
- Maybe reply: chickey <email protected>: "Re: [PHP-DB] Database access using ODBC"
- Maybe reply: chickey <email protected>: "RE: [PHP-DB] Database access using ODBC"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Jorge Alvarez: "Re: [PHP-DB] Interbase Problem"
- Previous message: Adam Lundrigan: "[PHP-DB] Is MySQL in 4.0.6?"
- Next in thread: Miles Thompson: "Re: [PHP-DB] Database access using ODBC"
- Reply: Miles Thompson: "Re: [PHP-DB] Database access using ODBC"
- Maybe reply: chickey <email protected>: "Re: [PHP-DB] Database access using ODBC"
- Maybe reply: chickey <email protected>: "RE: [PHP-DB] Database access using ODBC"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

