473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

db2/php random error

Note: deliberately xposted to the two newsgroups which seem applicable,
after reading several hundred messages from various php groups.

Randomly my application gets the message:

Warning: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û,
SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW @Ôªÿ¿ in
SQLConnect in /var/www/html/GEM/db.php on line 15
db.php is a common module used throughout my application. The error
(with various random trash in the middle) sometime occurs just as the
application is entered for the first time, sometimes after many
minutes/hours of successful operation. The routine, slightly masked for
security appears below. I am running php v 4.3.4 (--with-ibm-db2) and
db2 v 8.1.5 under apache 2.0 on redhat v 8.0.

Any assistance (including RTFM with references, because I have RTFM
until I am cross-eyed) would be greatly appreciated.

<?php
// vim: set ts=4 sw=4 ai:
function showerror($dbConn) {
echo "<br>";
echo "Error ".odbc_error($dbConn)." ".odbc_errormsg($dbConn);
echo "<br>";
}
function conn() {
global $schema, $database;
$schema = "is3";
$database = "animalst";
$dbuser = "xxxxxxxx";
$dbpwd = "xxxxxxxx";
$dbConn = odbc_connect($database,$dbuser,$dbpwd);
if ( $dbConn===False) {
showerror($dbConn);
die("could not connect to $database");
}
return $dbConn;
}
?>

Jul 17 '05 #1
12 1945
Robert Stearns wrote:
Note: deliberately xposted to the two newsgroups which seem applicable,
after reading several hundred messages from various php groups.

Randomly my application gets the message:

Warning: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û,
SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW @Ôªÿ¿ in
SQLConnect in /var/www/html/GEM/db.php on line 15
db.php is a common module used throughout my application. The error
(with various random trash in the middle) sometime occurs just as the
application is entered for the first time, sometimes after many
minutes/hours of successful operation. The routine, slightly masked for
security appears below. I am running php v 4.3.4 (--with-ibm-db2) and
db2 v 8.1.5 under apache 2.0 on redhat v 8.0.

Any assistance (including RTFM with references, because I have RTFM
until I am cross-eyed) would be greatly appreciated.

<?php
// vim: set ts=4 sw=4 ai:
function showerror($dbConn) {
echo "<br>";
echo "Error ".odbc_error($dbConn)." ".odbc_errormsg($dbConn);
echo "<br>";
}
function conn() {
global $schema, $database;
$schema = "is3";
$database = "animalst";
$dbuser = "xxxxxxxx";
$dbpwd = "xxxxxxxx";
$dbConn = odbc_connect($database,$dbuser,$dbpwd);
if ( $dbConn===False) {
showerror($dbConn);
die("could not connect to $database");
}
return $dbConn;
}
?>

could it be some number of connections allowable in DB2 or some resource
that you could be exhausting at the time of problem? You are generally
looking at a resource issue when things work "randomly". CPU, Memory,
database connections count, allowable sockets, Apache connections
available, locking in the database -- this list can go on for a very
long time.... You might also check your ODBC and any applicable GEM
parameters as well.

Not real clear which OS, but obviously some sort of ?***X.

I know that is not a lot of help, and you have probably exhausted your
brain by now, just a fresh perspective....
Michael Austin.
BTW, if you need an onsite consultant... :)

Jul 17 '05 #2
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Note: deliberately xposted to the two newsgroups which seem applicable,
after reading several hundred messages from various php groups.

Randomly my application gets the message:

Warning: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û,
SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW @Ôªÿ¿ in
SQLConnect in /var/www/html/GEM/db.php on line 15
db.php is a common module used throughout my application. The error
(with various random trash in the middle) sometime occurs just as the
application is entered for the first time, sometimes after many
minutes/hours of successful operation. The routine, slightly masked for
security appears below. I am running php v 4.3.4 (--with-ibm-db2) and
db2 v 8.1.5 under apache 2.0 on redhat v 8.0.

Any assistance (including RTFM with references, because I have RTFM
until I am cross-eyed) would be greatly appreciated.

<?php
// vim: set ts=4 sw=4 ai:
function showerror($dbConn) {
echo "<br>";
echo "Error ".odbc_error($dbConn)." ".odbc_errormsg($dbConn);
echo "<br>";
}
function conn() {
global $schema, $database;
$schema = "is3";
$database = "animalst";
$dbuser = "xxxxxxxx";
$dbpwd = "xxxxxxxx";
$dbConn = odbc_connect($database,$dbuser,$dbpwd);
$dbConn = @odbc_connect($database,$dbuser,$dbpwd);

The @ at the start of the function will supress any error messages/warning
generated by the function.
if ( $dbConn===False) {


printf("[%s][%s][%s]<br>\n" , $database,$dbuser,$dbpwd);

Check the parameters you are passing to connect function, as they are more
likely to show you what is going wrong. It's unlikely in this case as you've
set them just before calling the connect function.

Check your odbc/php setup, and increase the timeout settings for which ever
database you are using.

Consider using adodb http://adodb.sourceforge.net/ as your database
abstraction layer instead.

Jul 17 '05 #3
"CJ Llewellyn" <sa****@tmslifeline.com> wrote in message
news:cc**********@slavica.ukpost.com...
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...

-snip-
Any assistance (including RTFM with references, because I have RTFM
until I am cross-eyed) would be greatly appreciated.


Actually thinking about it, you do need to RTFM!

http://uk2.php.net/manual/en/function.odbc-connect.php
DSN is not a database name as per the other types of database connection
string, but a string describing what database to connect to, and which
driver to use.

Jul 17 '05 #4
CJ Llewellyn wrote:
"CJ Llewellyn" <sa****@tmslifeline.com> wrote in message
news:cc**********@slavica.ukpost.com...
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...


-snip-
Any assistance (including RTFM with references, because I have RTFM
until I am cross-eyed) would be greatly appreciated.

Actually thinking about it, you do need to RTFM!

http://uk2.php.net/manual/en/function.odbc-connect.php
DSN is not a database name as per the other types of database connection
string, but a string describing what database to connect to, and which
driver to use.

Actually, since I am using the compiled-in db2 on localhost (the
default), it would appear that the only value I need in DSN is the
database name, 'animalst'. And considering that it does succeed more
often than not, that is unlikely to be the cause of my problem. However,
when we grow to have separate web and db servers, I will have to revisit
this question and may need further help, since the exact value of the
DSN string seems to vary with the target db/system.

Jul 17 '05 #5
Thanks for such a quick reply.

CJ Llewellyn wrote:
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Note: deliberately xposted to the two newsgroups which seem applicable,
after reading several hundred messages from various php groups.

Randomly my application gets the message:

Warning: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û,
SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW @Ôªÿ¿ in
SQLConnect in /var/www/html/GEM/db.php on line 15

function conn() {
global $schema, $database;
$schema = "is3";
$database = "animalst";
$dbuser = "xxxxxxxx";
$dbpwd = "xxxxxxxx";
$dbConn = odbc_connect($database,$dbuser,$dbpwd);

$dbConn = @odbc_connect($database,$dbuser,$dbpwd);

The @ at the start of the function will supress any error messages/warning
generated by the function.

if ( $dbConn===False) {

printf("[%s][%s][%s]<br>\n" , $database,$dbuser,$dbpwd);

I will try these to see if they are corrupted by earlier code. I hope
not, finding where I corrupt constants will be a real challenge in an
interpreted language :-)
Check the parameters you are passing to connect function, as they are more
likely to show you what is going wrong. It's unlikely in this case as you've
set them just before calling the connect function.

Check your odbc/php setup, and increase the timeout settings for which ever
database you are using.
Which parameters? We are rank amateurs in setting the things up, and
have mostly taken the defaults, since our machine is reasonably fast,
their reasonably few users now, and the database is reasonably small
now. We thought to have to work on tuning parameters as we grew and had
more time.
Consider using adodb http://adodb.sourceforge.net/ as your database
abstraction layer instead.
Is it less prone to these types of errors. Is it as powerful as raw
SQL/odbc? How much application code am I looking at having to replace
over the SQL/odbc abstraction layer?


Jul 17 '05 #6
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
-snip-
Actually, since I am using the compiled-in db2 on localhost (the
default), it would appear that the only value I need in DSN is the
database name, 'animalst'. And considering that it does succeed more
often than not, that is unlikely to be the cause of my problem. However,
when we grow to have separate web and db servers, I will have to revisit
this question and may need further help, since the exact value of the
DSN string seems to vary with the target db/system.


Try "DSN=animalst" as the DSN setting.

Jul 17 '05 #7
Robert Stearns wrote:
Note: deliberately xposted to the two newsgroups which seem applicable,
after reading several hundred messages from various php groups.

Randomly my application gets the message:

Warning: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û,
SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW @Ôªÿ¿ in
SQLConnect in /var/www/html/GEM/db.php on line 15


99.999% of the time this is caused by not sourcing db2profile and
therefore your DB2 environment is not set. Most importantly, the
environment variable DB2INSTANCE must be set. Typically, this is done
by sourcing db2profile in your Apache init script (/etc/init.d/httpd or
apachectl, depending on how Apache is installed on your system):

Somewhere near the top of your init script or apachectl file, put the
following:

# Source DB2 environment
.. /home/db2inst1/sqllib/db2profile

Replace the path with that of your instance installation location and
then stop and start Apache (don't just restart, you need to kill the
currently running processes for these changes to take effect).

HTH,

Derek
Jul 17 '05 #8
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Thanks for such a quick reply.

-snip-
Check your odbc/php setup, and increase the timeout settings for which ever database you are using.

Which parameters? We are rank amateurs in setting the things up, and
have mostly taken the defaults, since our machine is reasonably fast,
their reasonably few users now, and the database is reasonably small
now. We thought to have to work on tuning parameters as we grew and had
more time.


Look at any setting the deal with connection timeouts. There will be a
section for odbc connections in php.ini, and possibly one in the ODBC
connection driver.
Consider using adodb http://adodb.sourceforge.net/ as your database
abstraction layer instead.

Is it less prone to these types of errors. Is it as powerful as raw
SQL/odbc? How much application code am I looking at having to replace
over the SQL/odbc abstraction layer?


It's supposed to be a M$ ADO replacement API. Which will give you a OOP
method of accessing the data. It should be more efficient and portable than
the ODBC interface as it will use native database drivers and connections
where possible, and fall back to ODBC where not.

You'd have to replace all your current odbc calls, but the SQL statements
should remain compatible.


Jul 17 '05 #9
Derek Battams wrote:
Robert Stearns wrote:
Note: deliberately xposted to the two newsgroups which seem
applicable, after reading several hundred messages from various php
groups.

Randomly my application gets the message:

Warning: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û,
SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW @Ôªÿ¿
in SQLConnect in /var/www/html/GEM/db.php on line 15

99.999% of the time this is caused by not sourcing db2profile and
therefore your DB2 environment is not set. Most importantly, the
environment variable DB2INSTANCE must be set. Typically, this is done
by sourcing db2profile in your Apache init script (/etc/init.d/httpd or
apachectl, depending on how Apache is installed on your system):

Somewhere near the top of your init script or apachectl file, put the
following:

# Source DB2 environment
. /home/db2inst1/sqllib/db2profile

Replace the path with that of your instance installation location and
then stop and start Apache (don't just restart, you need to kill the
currently running processes for these changes to take effect).

HTH,

Derek


I added the following lines to the apachectl file:

# pick up any necessary db2 environment variables
if test -f /db2home/db2inst1/sqllib/db2profile; then
. /db2home/db2inst1/sqllib/db2profile
fi

I then stopped httpd, made sure that all tasks ended, and then
started it back up.

That did not cure the problem, so I rebooted the server completely, to
no beneficial effect. I also printed as much hex of the message as I
could, in the (crushed) hope that it would mean something me. It is
appended below.

Error number ýÿÿÿ¼=X'fdffffffbc12';
Error message O*@|VA°¸ÿ¿Û=X'064f2a407c1a5641b0b8ffbfdb03';

Any further pointers would be greatly appreciated.

Jul 17 '05 #10
CJ Llewellyn wrote:
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
Thanks for such a quick reply.


-snip-
Check your odbc/php setup, and increase the timeout settings for which
ever
database you are using.


Which parameters? We are rank amateurs in setting the things up, and
have mostly taken the defaults, since our machine is reasonably fast,
their reasonably few users now, and the database is reasonably small
now. We thought to have to work on tuning parameters as we grew and had
more time.

Look at any setting the deal with connection timeouts. There will be a
section for odbc connections in php.ini, and possibly one in the ODBC
connection driver.


After examining the output of phptest closely, I only found one timeout
involving databases:mysql.connect_timeout. Since it does not appear to
affect db2/odbc, I am loathe to change it. I saw no timeouts associated
with db2/odbc in php. Could there be something in apache?

Any further suggestions would be appreciated.

Jul 17 '05 #11
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com...
-snip-
After examining the output of phptest closely, I only found one timeout
involving databases:mysql.connect_timeout. Since it does not appear to
affect db2/odbc, I am loathe to change it. I saw no timeouts associated
with db2/odbc in php. Could there be something in apache?

Any further suggestions would be appreciated.


Write a loop to attempt to connect more than once before giving up
Jul 17 '05 #12
Robert Stearns wrote:
Derek Battams wrote:
Robert Stearns wrote:
Note: deliberately xposted to the two newsgroups which seem
applicable, after reading several hundred messages from various php
groups.

Randomly my application gets the message:

Warning: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û,
SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW @Ôªÿ¿
in SQLConnect in /var/www/html/GEM/db.php on line 15


99.999% of the time this is caused by not sourcing db2profile and
therefore your DB2 environment is not set. Most importantly, the
environment variable DB2INSTANCE must be set. Typically, this is done
by sourcing db2profile in your Apache init script (/etc/init.d/httpd
or apachectl, depending on how Apache is installed on your system):

Somewhere near the top of your init script or apachectl file, put the
following:

# Source DB2 environment
. /home/db2inst1/sqllib/db2profile

Replace the path with that of your instance installation location and
then stop and start Apache (don't just restart, you need to kill the
currently running processes for these changes to take effect).

HTH,

Derek

I added the following lines to the apachectl file:

# pick up any necessary db2 environment variables
if test -f /db2home/db2inst1/sqllib/db2profile; then
. /db2home/db2inst1/sqllib/db2profile
fi

I then stopped httpd, made sure that all tasks ended, and then
started it back up.

That did not cure the problem, so I rebooted the server completely, to
no beneficial effect. I also printed as much hex of the message as I
could, in the (crushed) hope that it would mean something me. It is
appended below.

Error number ýÿÿÿ¼=X'fdffffffbc12';
Error message O*@|VA°¸ÿ¿Û=X'064f2a407c1a5641b0b8ffbfdb03';

Any further pointers would be greatly appreciated.


Sorry, the only time I've ever seen this type of behaviour is when the
DB2 environment is not set. Are you able to connect to the DB2 instance
from the CLP with no issues?

The only other thing I can think of is that perhaps you recently
upgraded your DB2 installation and did not recompile the PHP module to
use the upgraded DB2 client library? Other than that, I'd suggest
contacting DB2 support.

HTH,

Derek
Jul 17 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Acacia | last post by:
How would you generate a random number in C++?
4
by: Robert Scheer | last post by:
Hi. Reading about the Math.random method I saw that by default it generates between 0 and 1. To generate numbers between a greater range I can use these syntaxes: x = Math.random()/10 x =...
10
by: Virus | last post by:
Ok well what I am trying to do is have 1.) the background color to change randomly with 5 different colors.(change on page load) 2,) 10 different quotes randomly fadeing in and out in random...
16
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have...
1
by: John C | last post by:
Hi, I am trying to include the generation of random numbers in my c++ class. However I don't quite know how to incorporate it. To start with, I managed to get random numbers going via the...
9
by: greeningster | last post by:
I have written an application in Visual C++ for a customer but it seems to crash randomly. Could anyone give me any help on how I could track this down ? Also, there appears there might be...
10
by: Marshall Belew | last post by:
I'm trying to synchronize a network app that uses random numbers generated by System.Random. Rather than pass every randomly generated number, I just pass the seed. I'm seeing a result that leads...
5
by: jar13861 | last post by:
I'm confused on how to write a random array that will only generate 9 different numbers from 1-9. Here is what I have, but its only writing one number.... holder = new Array ( 9 ); var flag =...
1
by: ssims | last post by:
I've got this code for a random GDI+ chart generator, and the demo works, but when I try to run it on my local machine I get a compiler error: Compiler Error Message: CS0117: 'Random' does not...
0
by: urkel | last post by:
Hello everybody, I have these errors on C program that may be because of random number definition. I use an SSH to compile C like in Linux. May be you have idea whether the errors are due to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.