[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

query php in iseries

Posted on 2006-05-07
9
Medium Priority
?
891 Views
Last Modified: 2013-12-12
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
0
Comment
Question by:andretty76
  • 7
  • 2
9 Comments
 

Author Comment

by:andretty76
ID: 16624655
Forgive my English, I am really urgent for making it work
please
thanks

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16624666
I assume that you want to compare the column $AAC08 to a string 'PER' :
$sql = "SELECT * FROM CCOP2XBDT.F5Z7501 WHERE F5Z7501.$AAC08 = 'PER' ";
0
 

Author Comment

by:andretty76
ID: 16630505
Thank you, if really what I want is to filter the information of this table for the column $AAC08
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:andretty76
ID: 16630771
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
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 16630779
did you try my suggestion?
0
 

Author Comment

by:andretty76
ID: 16630795
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
 

Author Comment

by:andretty76
ID: 16630999
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
 

Author Comment

by:andretty76
ID: 16633198
help me
0
 

Author Comment

by:andretty76
ID: 16639032


HELLO , I WANT TO KNOW IF SOMEONE CAN HELP ME OR IF REALLY IT IS THAT THEY HAVE NOT UNDERSTOOD MY QUESTION
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month18 days, 1 hour left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question