When I run this script , I have a error :
Warning: Invalid argument supplied for foreach() in C:\Apache\test.php on line 28
<?php
$conn =OCILogon("xxxx", "yyyy", "localhost/xe");
$query = 'SELECT *FROM TEST';
$stid = OCIParse($conn, $query);
print '</br>';
$stmt=OCIParse($conn,'SELECT *FROM TEST');
$ret=OCIExecute($stmt);
$nrows=OCIFetch($stmt,$results);
if ($nrows>0)
{
echo "<table border='1' align='left' bordercolor='gray' cellspacing='0' cellpadding='5'> \n";
echo "<tr>\n";
foreach ($results as $key => $val)
{ echo "<th bgcolor='yellow' height='20' align='left'> <font color='b' face='verdana' size='2'> $key </font> </th> \n";
}
echo "</tr>\n";
for ($i=0; $i<$nrows; $i++) {
echo "<tr>\n";
foreach ($results as $data){
if($data[$i] == null)
{
echo "<td bgcolor='white' align='left'> <FONT COLOR='black' FACE='verdana' align='left' SIZE='3'>   </FONT> </td>\n";
}
else
if($data[$i] == 'FAIL')
{
echo "<td bgcolor='red' > <FONT COLOR='black' FACE='verdana' SIZE='2'> $data[$i] </font> </td> \n";
}
else
{
echo "<td bgcolor='white' > <FONT COLOR='black' FACE='verdana' SIZE='2'> $data[$i] </font> </td> \n";
}
}
echo "</tr>\n";
}
echo "<table> \n";
}else
{
echo '<font color="red"> missing id <br/> </font>';
}
//oci_free_statement($stmt);
OCIFreeStatement($stmt);
OCILogoff($conn);
I modify this code and insert (array) :
foreach ((array)$results as $key => $val)
{ echo "<th bgcolor='yellow' height='20' align='left'> <font color='b' face='verdana' size='2'> $key </font> </th> \n";
}
echo "</tr>\n";
for ($i=0; $i<$nrows; $i++) {
echo "<tr>\n";
foreach ((array)$results as $data){
if($data[$i] == null)
{
echo "<td bgcolor='white' align='left'> <FONT COLOR='black' FACE='verdana' align='left' SIZE='3'>   </FONT> </td>\n";
}
else
if($data[$i] == 'FAIL')
{
echo "<td bgcolor='red' > <FONT COLOR='black' FACE='verdana' SIZE='2'> $data[$i] </font> </td> \n";
}
else
{
echo "<td bgcolor='white' > <FONT COLOR='black' FACE='verdana' SIZE='2'> $data[$i] </font> </td> \n";
}
}
echo "</tr>\n";
}
echo "<table> \n";
}else
{
echo '<font color="red"> Dzisiaj jeszcze nie byly uruchamiane TESTY <br/> </font>';
}
Now I have a blank page , I dont have eny errors and any value on www
anyone have any idea?