query php in iseries

I am connecting a page of php to a servant iseries ibm, this it(he,she) connects me without problem but when I try filterthe information the following mistake goes out for me

Warning: odbc_exec(): SQL error: [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token = was not valid. Valid tokens: DAY RRN CAST CHAR DATE DAYS HASH HOUR LEFT TIME TRIM YEAR COUNT., SQL state 37000 in SQLExecDirect in c:\appserv\www\new_intra\odbc\funciona2.php on line 11


this is the code

<?php

$conn = odbc_connect('FACTURACION','AFCORTES','ARDFGR');
$nrows=0;

if ($conn)
{
$sql = "SELECT * FROM CCOP2XBDT.F5Z7501 WHERE F5Z7501.$AAC08 = PER ";

//this function will execute the sql satament
$result=odbc_exec($conn, $sql);

echo "<table align=\"center\" border=\"1\" borderColor=\"\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr> ";
// -- print field name
$colName = odbc_num_fields($result);
for ($j=1; $j<= $colName; $j++)
{
echo "<th align=\"left\" bgcolor=\"#CCCCCC\" > <font color=\"#990000\"> ";
echo odbc_field_name ($result, $j );
echo "</font> </th>";
}
$j=$j-1;
$c=0;
// end of field names
while(odbc_fetch_row($result)) // getting data
{
$c=$c+1;
if ( $c%2 == 0 )
echo "<tr bgcolor=\"#d0d0d0\" >\n";
else
echo "<tr bgcolor=\"#eeeeee\">\n";
for($i=1;$i<=odbc_num_fields($result);$i++)
{
echo "<td>";
echo odbc_result($result,$i);
echo "</td>";
if ( $i%$j == 0 )
{
$nrows+=1; // counting no of rows
}
}
echo "</tr>";
}

echo "</td> </tr>\n";
echo "</table >\n";
// --end of table
if ($nrows==0) echo "<br/><center> Sin datos $month que concuerden con su busqueda</center> <br/>";
else echo "<br/><center> Total Records: $nrows </center> <br/>";
odbc_close ($conn);

}
else echo "odbc not connected <br>";
?>

help me please
andretty76Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
did you try my suggestion?
0
 
andretty76Author Commented:
Forgive my English, I am really urgent for making it work
please
thanks

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I assume that you want to compare the column $AAC08 to a string 'PER' :
$sql = "SELECT * FROM CCOP2XBDT.F5Z7501 WHERE F5Z7501.$AAC08 = 'PER' ";
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
andretty76Author Commented:
Thank you, if really what I want is to filter the information of this table for the column $AAC08
0
 
andretty76Author Commented:
The mistake this one in this code but not that is
sql = "SELECT * FROM CCOP2XBDT.F5Z7501 WHERE F5Z7501.$AAC08 = PER ";

PER CORRESPONDS TO a  CITY  ABBREVIATION OF COLOMBIA
0
 
andretty76Author Commented:
THIS ONE IS THE CODE THAT IF IT WORKS

<?php

$conn = odbc_connect('FACTURACION','AFCORTES','cemex2006');
$nrows=0;

if ($conn)
{
$sql =  "SELECT * FROM CCOP2XBDT.F5Z7501 WHERE AAC08 = $PER ";

//this function will execute the sql satament
$result=odbc_exec($conn, $sql);

echo "<table  align=\"center\" border=\"1\" borderColor=\"\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr> ";
// -- print field name
$colName = odbc_num_fields($result);
for ($j=1; $j<= $colName; $j++)
{
echo "<th  align=\"left\" bgcolor=\"#CCCCCC\" > <font color=\"#990000\"> ";
echo odbc_field_name ($result, $j );
echo "</font> </th>";
}
$j=$j-1;
$c=0;
// end of field names
while(odbc_fetch_row($result)) // getting data
{
 $c=$c+1;
 if ( $c%2 == 0 )
 echo "<tr bgcolor=\"#d0d0d0\" >\n";
 else
 echo "<tr bgcolor=\"#eeeeee\">\n";
   for($i=1;$i<=odbc_num_fields($result);$i++)
     {        
       echo "<td>";
       echo odbc_result($result,$i);
       echo "</td>";        
       if ( $i%$j == 0 )  
           {
           $nrows+=1; // counting no of rows    
         }  
     }
   echo "</tr>";
}

echo "</td> </tr>\n";
echo "</table >\n";
// --end of table  
if ($nrows==0) echo "<br/><center> Sin datos $month  que concuerden con su busqueda</center>  <br/>";
else echo "<br/><center> Total Records:  $nrows </center>  <br/>";
odbc_close ($conn);

}
else echo "odbc not connected <br>";
?>
0
 
andretty76Author Commented:
With what you said to your me the following mistake goes out

Warning: odbc_exec(): SQL error: [IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token = was not valid. Valid tokens: ( + - ? : DAY NOT RRN CASE CAST CHAR DATE DAYS HASH HOUR LEFT., SQL state 37000 in SQLExecDirect in c:\appserv\www\new_intra\odbc\funciona2.php on line 11


this is the code

$sql =  "SELECT * FROM CCOP2XBDT.F5Z7501 WHERE $AAC08 = 'PER' ";
0
 
andretty76Author Commented:
help me
0
 
andretty76Author Commented:


HELLO , I WANT TO KNOW IF SOMEONE CAN HELP ME OR IF REALLY IT IS THAT THEY HAVE NOT UNDERSTOOD MY QUESTION
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.