Hi there,
We have just installed Merants drivers for Progress and ODBC. We are using PHP4.0.4 on a win nt machine with version 3.51 of ODBC administrator. In our code we are trying to grab more than one row, whatever customer ID is less than 15. What we are receiving on the page is the first record, 15 TIMES. So odbc_fetch_row is not moving the internal pointer to the next row in the fetch. We have seen glimpses of this same problem on the internet where other people had this issue, but no one has an answer. We are assuming it is a driver issue but we don't know if it's MS's ODBC, Merants Progress .dll, or PHP 4. We would appreciate any help! For reference...our code is:

$result = odbc_connect("dsn", "username", "password") or die ("cannot connect");

$sth=odbc_prepare($result,"SELECT CustNum, Name FROM PUB.customer WHERE customer.CustNum < '15'") or die("cannot do");
if(odbc_execute($sth))
{
while (odbc_fetch_row($sth)) {
echo odbc_result($sth, 1);
echo "&nbsp;&nbsp;&nbsp;";
echo odbc_result($sth, 2);
echo "<br>\n";
}
}
else{
echo"execute failed.";

And our output is:
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours
1 Lift Tours

Thanks in advance for any help!

    We have already installed Microsoft Data Access Components (MDAC) 2.1.2.4202.3 as an attempt to update all the drivers

      Try using odbc_fetch_into as opposed to _fetch_row.

      Resulting code:
      $result = odbc_connect("dsn", "username", "password") or die ("cannot connect");

      $sth=odbc_prepare($result,"SELECT CustNum, Name FROM PUB.customer WHERE customer.CustNum < '15'") or die("cannot do");
      if(odbc_execute($sth))
      {
      while (odbc_fetch_into($sth)) {
      echo odbc_result($sth, 1);
      echo " ";
      echo odbc_result($sth, 2);
      echo "<br>\n";
      }
      }
      else{
      echo"execute failed.";

      Steveness

        OK, I changed the fetch line to
        while(odbc_fetch_into($sth, &$row))

        and it is still giving me the first record 15 times. I don not think this is a coding error. I honestly believe there is a driver problem....if anyone can come up with coding to force the move or have ideas on the driver problems please please let us know!

        Thanks in advance

          Try this:

          $sth=odbc_prepare($result,"SELECT CustNum, Name FROM PUB.customer WHERE customer.CustNum < '15'") or die("cannot do");
          if(odbc_execute($sth))
          {
          while (odbc_fetch_into($sth, &$row)) {
          echo "$row[0]";
          echo " ";
          echo "$row[1]";
          echo "<br>\n";
          }
          }
          else{
          echo"execute failed.";

          I think the problem is the odbc_result you are using. This should solve the problem.

          Steveness

            Ok, i changed the code to what you have above and i'm still getting this:
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours
            1Better Lift Tours

            Any other ideas? (And thanks for you help so far!)

              do this:

              while ($res = odbc_fetch_row($sth)) {
              echo odbc_result($res, 1);

                Ok, now i don't get data printed I get this error:
                Warning: Supplied argument is not a valid ODBC result resource in E:\inetpub\wwwroot\Alpine Communications\progress_test.php on line 16

                  For those of you interested in this thread or will be in the future (I hate when people find out the answer and don't post it for the rest of us!) My hunch was right, the code was always good, it was the ODBC drivers. We received the drivers from Progress that they bought from Merant. We're not sure still if we could have eventually tweaked them, but we found some FREE drivers at openlinksw.com for multi-tier that once we installed, it ran beautifully! no more staying on one record! Thanks everyone for your help 🙂
                  Tinny

                    2 months later

                    Hi,

                    It's not a ODBC problem but a "PHP" problem, rather is a problem in your code!!.

                    In the odbc_connect you have to add the constant: SQL_CUR_USE_ODBC. It would be like this:

                    odbc_connect("dsn", "username", "password",
                    SQL_CUR_USE_ODBC)

                    With this it will work.

                    You can see kb 21017 that shows an example about PHP and Progress in: http://www.progress.com/support/kb/index.htm,then you choose option: Search Knowledge Base and you write kbase: 21017.

                    Regards,
                    Juan.

                      Write a Reply...