This is a discussion on PHP - DB2 weird error while refreshing page within the DB2 forums, part of the Database Server Software category; --> Hello. I have developed a medical application with php 4 linked to IBM DB2 database. The database connection is ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello. I have developed a medical application with php 4 linked to IBM DB2 database. The database connection is right and i can access data with no problem...but sometimes when i reload the page which has been already loaded (by pressing CTRL-R) i receive an SQL STATE Error: "(...) SQL State: X (..)" it looks like the error i receive when i was having my first trouble with ibm db2 as i did not exported the DB2 istance. but i can not understand while sometimes it works and sometimes no... anyone can help me? regards crunix. |
| |||
| "crunix" <crunix83@spymac.com> wrote in message news:4up9i0dhpmhqqjp3jkltan7fcd77rop111@4ax.com... > Hello. > > I have developed a medical application with php 4 linked to IBM DB2 > database. > > The database connection is right and i can access data with no > problem...but sometimes when i reload the page which has been already > loaded (by pressing CTRL-R) i receive an SQL STATE Error: > > "(...) SQL State: X (..)" > > it looks like the error i receive when i was having my first trouble > with ibm db2 as i did not exported the DB2 istance. > > but i can not understand while sometimes it works and sometimes no... > anyone can help me? > Which particular SQLState are you getting in the error message? The precise value will enable people to have some idea of what might be wrong. It will also enable you to look this up for yourself in the DB2 manuals. Also, the SQLCode is often more useful than the SQLState since the messages for the SQLCode are more detailed. If you can determine the SQLCode, that would be very helpful. Rhino |
| |||
| Sometimes SQLSTATE is unreadeble other times it is just like this one: SQLState: X On Thu, 19 Aug 2004 15:10:13 -0400, "Rhino" <rhino1@NOSPAM.sympatico.ca> wrote: > >"crunix" <crunix83@spymac.com> wrote in message >news:4up9i0dhpmhqqjp3jkltan7fcd77rop111@4ax.com.. . >> Hello. >> >> I have developed a medical application with php 4 linked to IBM DB2 >> database. >> >> The database connection is right and i can access data with no >> problem...but sometimes when i reload the page which has been already >> loaded (by pressing CTRL-R) i receive an SQL STATE Error: >> >> "(...) SQL State: X (..)" >> >> it looks like the error i receive when i was having my first trouble >> with ibm db2 as i did not exported the DB2 istance. >> >> but i can not understand while sometimes it works and sometimes no... >> anyone can help me? >> >Which particular SQLState are you getting in the error message? The precise >value will enable people to have some idea of what might be wrong. It will >also enable you to look this up for yourself in the DB2 manuals. > >Also, the SQLCode is often more useful than the SQLState since the messages >for the SQLCode are more detailed. If you can determine the SQLCode, that >would be very helpful. > >Rhino > |
| |||
| I think you'll need to improve the error handling in your php program. I don't know the php language myself but every other language I know offers ways to display the values of SQLState, SQLCode, and often the SQLMessage. All you have to do is display those values if your program hits an unexpected condition. I don't know if php and Perl are related - they certainly *look* similar - but this fragment from the Application Development Guide shows how to store the values of the SQLState and the SQLCode in Perl. Perhaps the technique for php is the same? ---------------------------------------------------------------------------- ---------------------------------- To return the SQLSTATE associated with a Perl DBI database handle or statement handle, call the state method. For example, to return the SQLSTATE associated with the database handle $dbhandle, include the following Perl statement in your application: my $sqlstate = $dbhandle->state; To return the SQLCODE associated with a Perl DBI database handle or statement handle, call the err method. To return the message for an SQLCODE associated with a Perl DBI database handle or statement handle, call the errstr method. For example, to return the SQLCODE associated with the database handle $dbhandle, include the following Perl statement in your application: my $sqlcode = $dbhandle->err; ---------------------------------------------------------------------------- ---------------------------------- When you know the SQLState and SQLCode, it will be MUCH easier to determine what your problem is. Rhino "crunix" <crunix83@spymac.com> wrote in message news:f97ai05aajgoevv2ctq90qi5r98a0rpvb8@4ax.com... > Sometimes SQLSTATE is unreadeble other times it is just like this one: > SQLState: X > > > > On Thu, 19 Aug 2004 15:10:13 -0400, "Rhino" > <rhino1@NOSPAM.sympatico.ca> wrote: > > > > >"crunix" <crunix83@spymac.com> wrote in message > >news:4up9i0dhpmhqqjp3jkltan7fcd77rop111@4ax.com.. . > >> Hello. > >> > >> I have developed a medical application with php 4 linked to IBM DB2 > >> database. > >> > >> The database connection is right and i can access data with no > >> problem...but sometimes when i reload the page which has been already > >> loaded (by pressing CTRL-R) i receive an SQL STATE Error: > >> > >> "(...) SQL State: X (..)" > >> > >> it looks like the error i receive when i was having my first trouble > >> with ibm db2 as i did not exported the DB2 istance. > >> > >> but i can not understand while sometimes it works and sometimes no... > >> anyone can help me? > >> > >Which particular SQLState are you getting in the error message? The precise > >value will enable people to have some idea of what might be wrong. It will > >also enable you to look this up for yourself in the DB2 manuals. > > > >Also, the SQLCode is often more useful than the SQLState since the messages > >for the SQLCode are more detailed. If you can determine the SQLCode, that > >would be very helpful. > > > >Rhino > > > |
| |||
| To display SQLSTATE and SQLCODE values in a PHP program using the Unified ODBC driver, you can create a function like the following: function display_error($connection) { // odbc_errormsg returns last SQLCODE and error text $message = odbc_errormsg($connection); // odbc_error returns last SQLSTATE $sqlstate = odbc_error($connection); print("<p>Error message = $message</p>"); print("<p>SQLSTATE = $sqlstate</p>"); } Then you can call the function when you detect an error condition: $rc = odbc_exec($connection, $sql_statement); if ($rc == FALSE) { display_error($connection); } Hopefully this helps you retrieve some more useful information for debugging the problem. Dan P.S. Sorry for the late reply, my usual newsgroup server appears to be rather intermittent. Rhino wrote: > I think you'll need to improve the error handling in your php program. I > don't know the php language myself but every other language I know offers > ways to display the values of SQLState, SQLCode, and often the SQLMessage. > All you have to do is display those values if your program hits an > unexpected condition. > > I don't know if php and Perl are related - they certainly *look* similar - > but this fragment from the Application Development Guide shows how to store > the values of the SQLState and the SQLCode in Perl. Perhaps the technique > for php is the same? > > ---------------------------------------------------------------------------- > ---------------------------------- > To return the SQLSTATE associated with a Perl DBI database handle or > statement handle, call the state method. For example, to return the SQLSTATE > associated with the database handle $dbhandle, include the following Perl > statement in your application: > > my $sqlstate = $dbhandle->state; > To return the SQLCODE associated with a Perl DBI database handle or > statement handle, call the err method. To return the message for an SQLCODE > associated with a Perl DBI database handle or statement handle, call the > errstr method. For example, to return the SQLCODE associated with the > database handle $dbhandle, include the following Perl statement in your > application: > > my $sqlcode = $dbhandle->err; > ---------------------------------------------------------------------------- > ---------------------------------- > > When you know the SQLState and SQLCode, it will be MUCH easier to determine > what your problem is. > > Rhino > > "crunix" <crunix83@spymac.com> wrote in message > news:f97ai05aajgoevv2ctq90qi5r98a0rpvb8@4ax.com... > >>Sometimes SQLSTATE is unreadeble other times it is just like this one: >>SQLState: X >> >> >> >>On Thu, 19 Aug 2004 15:10:13 -0400, "Rhino" >><rhino1@NOSPAM.sympatico.ca> wrote: >> >> >>>"crunix" <crunix83@spymac.com> wrote in message >>>news:4up9i0dhpmhqqjp3jkltan7fcd77rop111@4ax.com ... >>> >>>>Hello. >>>> >>>>I have developed a medical application with php 4 linked to IBM DB2 >>>>database. >>>> >>>>The database connection is right and i can access data with no >>>>problem...but sometimes when i reload the page which has been already >>>>loaded (by pressing CTRL-R) i receive an SQL STATE Error: >>>> >>>>"(...) SQL State: X (..)" >>>> >>>>it looks like the error i receive when i was having my first trouble >>>>with ibm db2 as i did not exported the DB2 istance. >>>> >>>>but i can not understand while sometimes it works and sometimes no... >>>>anyone can help me? >>>> >>> >>>Which particular SQLState are you getting in the error message? The > > precise > >>>value will enable people to have some idea of what might be wrong. It > > will > >>>also enable you to look this up for yourself in the DB2 manuals. >>> >>>Also, the SQLCode is often more useful than the SQLState since the > > messages > >>>for the SQLCode are more detailed. If you can determine the SQLCode, that >>>would be very helpful. >>> >>>Rhino >>> >> > > |
| ||||
| Thanks a lot for your help, i'm going in newxt days to have some beta testing time...i will let you know if i solve my problem. Thanks crunix83 On Mon, 23 Aug 2004 10:23:13 -0400, Dan Scott <dan.scott@ca.ibm.com> wrote: >To display SQLSTATE and SQLCODE values in a PHP program using the >Unified ODBC driver, you can create a function like the following: > >function display_error($connection) { > // odbc_errormsg returns last SQLCODE and error text > $message = odbc_errormsg($connection); > > // odbc_error returns last SQLSTATE > $sqlstate = odbc_error($connection); > > print("<p>Error message = $message</p>"); > print("<p>SQLSTATE = $sqlstate</p>"); >} > >Then you can call the function when you detect an error condition: > >$rc = odbc_exec($connection, $sql_statement); >if ($rc == FALSE) { > display_error($connection); >} > >Hopefully this helps you retrieve some more useful information for >debugging the problem. > >Dan > >P.S. Sorry for the late reply, my usual newsgroup server appears to be >rather intermittent. > >Rhino wrote: >> I think you'll need to improve the error handling in your php program. I >> don't know the php language myself but every other language I know offers >> ways to display the values of SQLState, SQLCode, and often the SQLMessage. >> All you have to do is display those values if your program hits an >> unexpected condition. >> >> I don't know if php and Perl are related - they certainly *look* similar - >> but this fragment from the Application Development Guide shows how to store >> the values of the SQLState and the SQLCode in Perl. Perhaps the technique >> for php is the same? >> >> ---------------------------------------------------------------------------- >> ---------------------------------- >> To return the SQLSTATE associated with a Perl DBI database handle or >> statement handle, call the state method. For example, to return the SQLSTATE >> associated with the database handle $dbhandle, include the following Perl >> statement in your application: >> >> my $sqlstate = $dbhandle->state; >> To return the SQLCODE associated with a Perl DBI database handle or >> statement handle, call the err method. To return the message for an SQLCODE >> associated with a Perl DBI database handle or statement handle, call the >> errstr method. For example, to return the SQLCODE associated with the >> database handle $dbhandle, include the following Perl statement in your >> application: >> >> my $sqlcode = $dbhandle->err; >> ---------------------------------------------------------------------------- >> ---------------------------------- >> >> When you know the SQLState and SQLCode, it will be MUCH easier to determine >> what your problem is. >> >> Rhino >> >> "crunix" <crunix83@spymac.com> wrote in message >> news:f97ai05aajgoevv2ctq90qi5r98a0rpvb8@4ax.com... >> >>>Sometimes SQLSTATE is unreadeble other times it is just like this one: >>>SQLState: X >>> >>> >>> >>>On Thu, 19 Aug 2004 15:10:13 -0400, "Rhino" >>><rhino1@NOSPAM.sympatico.ca> wrote: >>> >>> >>>>"crunix" <crunix83@spymac.com> wrote in message >>>>news:4up9i0dhpmhqqjp3jkltan7fcd77rop111@4ax.co m... >>>> >>>>>Hello. >>>>> >>>>>I have developed a medical application with php 4 linked to IBM DB2 >>>>>database. >>>>> >>>>>The database connection is right and i can access data with no >>>>>problem...but sometimes when i reload the page which has been already >>>>>loaded (by pressing CTRL-R) i receive an SQL STATE Error: >>>>> >>>>>"(...) SQL State: X (..)" >>>>> >>>>>it looks like the error i receive when i was having my first trouble >>>>>with ibm db2 as i did not exported the DB2 istance. >>>>> >>>>>but i can not understand while sometimes it works and sometimes no... >>>>>anyone can help me? >>>>> >>>> >>>>Which particular SQLState are you getting in the error message? The >> >> precise >> >>>>value will enable people to have some idea of what might be wrong. It >> >> will >> >>>>also enable you to look this up for yourself in the DB2 manuals. >>>> >>>>Also, the SQLCode is often more useful than the SQLState since the >> >> messages >> >>>>for the SQLCode are more detailed. If you can determine the SQLCode, that >>>>would be very helpful. >>>> >>>>Rhino >>>> >>> >> >> |