GroundZero
Programmer
Hi everyone I am trying to understand something that php's been doing to me for 3 days now and I was hoping someone could tell me what's happening.
here is the problem:
I am using nested while loops but the first one need a semicolon ( to work and the second one won't work if I put one (seem to be going in an infinite loop)and won't work if I don't put it any idea why sometime I have to put the semicolon( and sometime I don't? I have never used a loop with it at the end and it was working.
also could you tell me what is wrong in my script loops?
//connect to database
$connect = odbc_connect("$DBname", "", "" or die("couldn't connect."
//query the user table for room and message
$query = "SELECT $DBselect FROM $DBtable";
if ($DBwhere!="none"
{
$query .= "WHERE $DBwhere=$DBfield";
}
//perform the query
$result = odbc_do($connect, $query);
$NbFields=odbc_num_fields($result);
$NbRows=odbc_num_rows($result);
$i=1;
$j=1;
while($i<=$NbRows);
{
odbc_fetch_row($result,$i);
while ($j <=$NbFields)
{
$A=odbc_field_name($result,$j);
$B=urlencode(odbc_result($result,$j));
print("$A$i=$B&"
$j++;
}
$i++;
}
print("ok=1&"
print("maxi=$i&"
//disconnect from database
odbc_close($connect);
break;
I send the needed var with the url box of the browser:
?DBname=rompDB1&DBselect=all&DBwhere=none&DBtable=User
thank you in advance,
GroundZero Your soul is imperfect
Life is difficult...
Now guess why we're here
here is the problem:
I am using nested while loops but the first one need a semicolon ( to work and the second one won't work if I put one (seem to be going in an infinite loop)and won't work if I don't put it any idea why sometime I have to put the semicolon( and sometime I don't? I have never used a loop with it at the end and it was working.
also could you tell me what is wrong in my script loops?
//connect to database
$connect = odbc_connect("$DBname", "", "" or die("couldn't connect."
//query the user table for room and message
$query = "SELECT $DBselect FROM $DBtable";
if ($DBwhere!="none"
{
$query .= "WHERE $DBwhere=$DBfield";
}
//perform the query
$result = odbc_do($connect, $query);
$NbFields=odbc_num_fields($result);
$NbRows=odbc_num_rows($result);
$i=1;
$j=1;
while($i<=$NbRows);
{
odbc_fetch_row($result,$i);
while ($j <=$NbFields)
{
$A=odbc_field_name($result,$j);
$B=urlencode(odbc_result($result,$j));
print("$A$i=$B&"
$j++;
}
$i++;
}
print("ok=1&"
print("maxi=$i&"
//disconnect from database
odbc_close($connect);
break;
I send the needed var with the url box of the browser:
?DBname=rompDB1&DBselect=all&DBwhere=none&DBtable=User
thank you in advance,
GroundZero Your soul is imperfect
Life is difficult...
Now guess why we're here