While attempting to alleviate a persistent but not consistent problem
with my database operation (DB2) I coded the do...while loop around my
odbc_connect. When $dbConn is false the first time, the program never
returns. This problem repeatable with or without the @ on the
odbc_connect call. I would someone pointing out my stupidity. I did
RTFM, including the examples, and was no further enlightened. Thanks in
advance.
function conn() {
global $schema, $database;
$schema = "is3";
$database = "animalst";
$dbuser = "db2inst1";
$dbpwd = "db2rules";
$ct = 0;
do {
$dbConn = odbc_connect($database,$dbuser,$dbpwd);
$ct += 1;
if($dbConn==False) { sleep(1); }
}
while(($dbConn==False) && ($ct<5)) ;
if ( $dbConn==False) {
printf("<br>The odbc_connect parameters were:[%s] [%s]
[%s]<br>\n" , $database,$dbuser,$dbpwd);
printf("<br>Tried %d times<br>\n",$ct);
showerror();
die("could not connect to $database");
}
return $dbConn;
}
? 2 2411
Robert Stearns wrote: While attempting to alleviate a persistent but not consistent problem with my database operation (DB2) I coded the do...while loop around my odbc_connect. When $dbConn is false the first time, the program never returns. This problem repeatable with or without the @ on the odbc_connect call. I would someone pointing out my stupidity. I did RTFM, including the examples, and was no further enlightened. Thanks in advance.
This might work out better (although I must point out that you should fix
your database if you really need a routine like this):
while (!($dbConn = odbc_connect($database,$dbuser,$dbpwd)) &&
(++$cnt < 5)) {
sleep(1);
}
JW
"Robert Stearns" <rs**********@charter.net> wrote in message
news:10*************@corp.supernews.com... While attempting to alleviate a persistent but not consistent problem with my database operation (DB2) I coded the do...while loop around my odbc_connect. When $dbConn is false the first time, the program never returns. This problem repeatable with or without the @ on the odbc_connect call. I would someone pointing out my stupidity. I did RTFM, including the examples, and was no further enlightened. Thanks in advance.
function conn() { global $schema, $database; $schema = "is3"; $database = "animalst"; $dbuser = "db2inst1"; $dbpwd = "db2rules"; $ct = 0; do { $dbConn = odbc_connect($database,$dbuser,$dbpwd); $ct += 1; if($dbConn==False) { sleep(1); } } while(($dbConn==False) && ($ct<5)) ; if ( $dbConn==False) { printf("<br>The odbc_connect parameters were:[%s] [%s] [%s]<br>\n" , $database,$dbuser,$dbpwd); printf("<br>Tried %d times<br>\n",$ct); showerror(); die("could not connect to $database"); } return $dbConn; } ?
As far as I can tell nothing in the PHP code should cause the loop to go
forever. Looks more like a ODBC driver issue to me. The driver must have
acquired some DB2 resouces before it failed, so that when you call
odbc_connect the second time, it deadlocks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: RobG |
last post by:
A little while ago I opined that do/while loops are harder to
read than for loops, and therefore I preferred using for loops.
However, it was pointed out that do/while has significant...
|
by: Rick |
last post by:
Hi,
For portability, can an issue arise if we use while(1) for an infinite
loop in C? If so, should we then use for(;;)? Thanks,
Rick
|
by: invni |
last post by:
I have a nested while. How do I go from the inner while to the
beginning of the outer while? Can this be done without using goto?
while_1()
{
some codes here
while_2()
{
if true go to the...
|
by: Michael B Allen |
last post by:
Should there be any preference between the following logically equivalent
statements?
while (1) {
vs.
for ( ;; ) {
I suspect the answer is "no" but I'd like to know what the consensus is
|
by: jvb |
last post by:
Hey all,
I figure it's Wednesday, why not put a question up for debate. Beyond
personal preference, is there any benefit (performance or otherwise) to
using one loop over the other? For example,...
|
by: monomaniac21 |
last post by:
hi all
i have a script that retrieves rows from a single table, rows are
related to eachother and are retrieved by doing a series of while loops
within while loops. bcos each row contains a text...
|
by: icarus |
last post by:
Hi all, i'm new to python. Learning on my own how to ask a user to
finish a loop or not.
For some reason, it behaves as infinite loop although I changed its
condition. Please tell me what I'm...
|
by: John Salerno |
last post by:
I know it's popular and very handy, but I'm curious if there are purists
out there who think that using something like:
for x in range(10):
#do something 10 times
is unPythonic. The reason I...
|
by: luislupe |
last post by:
Hi,
I've created a method where the script defines twenty variables and
several of them should be random having a maximum and a minimum value.
What I did was this:
from random import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |