By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,557 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,557 IT Pros & Developers. It's quick & easy.

PHP - DB2 weird error while refreshing page

P: n/a
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.
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"crunix" <cr******@spymac.com> wrote in message
news:4u********************************@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
Nov 12 '05 #2

P: n/a
Sometimes SQLSTATE is unreadeble other times it is just like this one:
SQLState: X

On Thu, 19 Aug 2004 15:10:13 -0400, "Rhino"
<rh****@NOSPAM.sympatico.ca> wrote:

"crunix" <cr******@spymac.com> wrote in message
news:4u********************************@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


Nov 12 '05 #3

P: n/a
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" <cr******@spymac.com> wrote in message
news:f9********************************@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"
<rh****@NOSPAM.sympatico.ca> wrote:

"crunix" <cr******@spymac.com> wrote in message
news:4u********************************@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 precisevalue will enable people to have some idea of what might be wrong. It willalso enable you to look this up for yourself in the DB2 manuals.

Also, the SQLCode is often more useful than the SQLState since the messagesfor the SQLCode are more detailed. If you can determine the SQLCode, that
would be very helpful.

Rhino

Nov 12 '05 #4

P: n/a
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" <cr******@spymac.com> wrote in message
news:f9********************************@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"
<rh****@NOSPAM.sympatico.ca> wrote:

"crunix" <cr******@spymac.com> wrote in message
news:4u********************************@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


Nov 12 '05 #5

P: n/a
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 <da*******@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" <cr******@spymac.com> wrote in message
news:f9********************************@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"
<rh****@NOSPAM.sympatico.ca> wrote:
"crunix" <cr******@spymac.com> wrote in message
news:4u********************************@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



Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.