Hi Miles, Andrew, rest of list,

After checking ODBC traces and stripping the code
down to the barebones, I found that there was two problems:

Firstly, trying to do too many things in one statement
didn't work, so I broke the following out into two
statements:

Was:
---

#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;
}

Now:
---

$DBConn = @odbc_pConnect($DBDsn, $DBUser, $DBPassword)
if (!$DBConn)
{
  echo "Database Execution Error: " . odbc_Error() . " " .  odbc_ErrorMsg();
  return false;
}


Secondly, (and I'm embarrassed about this one), the $DBQryID
variable I was using in the odbc_Exec command was being used
as $DBQryId (note the ending 'd' lowercase not uppercase as it
should be) and case sensitivity rules kicked in. After changing
these everything worked!

So, all in all, my only excuse is that this is the first time
I have tried out php and maybe this being explained above might
help out others trying for the first time too. As it is, I am
hooked. I never thought that developing an internet application
with database access could be as easy as php makes it.

Can I take the opportunity to say that for first time users (bearing
in mind that, hey, what do I know), I have found that the
combination of PHPEd as the editor I'm using with OmniHTTPD
(www.omnicron.ab.ca) as the web server is really nice for
testing everything on one machine. OmniHTTPD installs with ODBC
and PHP already setup. Just change the path in the preferences
in PHPEd to the php.exe that OmniHTTPD installs in its directory
and you're on the pigs back!

Anyway, thanks for all your help guys. See ya on the list!

Best Regards,

Colum Hickey

>    #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;


Original Message:
-----------------
From: Andrew Hill [EMAIL PROTECTED]
Date: Wed, 27 Jun 2001 14:16:39 -0400
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Database access using ODBC


Colum,

What does the ODBC trace show right after connection, and any subsequent
calls?

Best regards,
Andrew Hill
Director of Technology Evangelism
OpenLink Software  http://www.openlinksw.com
Universal Data Access & Data Integration Technology Providers

> -----Original Message-----
> From: Miles Thompson [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 26, 2001 1:55 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Database access using ODBC
>
>
> 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
>



--------------------------------------------------------------------
Mail2Web - Check your email from the web at
http://www.mail2web.com/ .


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to