[Web4lib] ODBC query in PHP

Mark Sandford sandfordm1 at wpunj.edu
Fri Dec 15 08:42:51 EST 2006


Well, I had two problems in my script.  The second one was that  my
debugging code was wrong, so I wasn't getting the error messages I needed.
I used Darryl's code in place of mine, and was able to work out that I
needed to specify the cursor in my odbc_connect string.

Thanks a lot to everyone who offered suggestions.

Mark

On 12/15/06, Darryl Friesen <Darryl.Friesen at usask.ca> wrote:
>
> > $result = odbc_exec($connection, $query)  ;
> >
> > Some basic error reporting tells me that the $result variable
> > is empty.
>
>
> One more thought, just for debugging.  What about something like this:
>
>
> $result = odbc_exec($connection, $query);
> if (empty($result))
> {
>   echo 'Query failed with error ' . odbc_error() . ': ' . odbc_errormsg()
> .
> "\n";
> }
>
>
> When the query fails you should at least get the error code and a textual
> message that hopefully will help in debugging (the web server's error log
> might also contain some hint, if you have access to that).
>
> - Darryl
>
> ----------------------------------------------------------------------
>   Darryl Friesen, B.Sc., Programmer/Analyst    Darryl.Friesen at usask.ca
>   Information Technology Services Division,     http://gollum.usask.ca/
>   University of Saskatchewan Library
> ----------------------------------------------------------------------
>   "Go not to the Elves for counsel, for they will say both no and yes"
>
> _______________________________________________
> Web4lib mailing list
> Web4lib at webjunction.org
> http://lists.webjunction.org/web4lib/
>



-- 
Mark Sandford
Special Formats Cataloger
William Paterson University
(973)270-2437
sandfordm1 at wpunj.edu


More information about the Web4lib mailing list