please help for beginner(php + ms access)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • peterlai@rotiprata.net

    please help for beginner(php + ms access)

    <html>
    <head>
    </head>

    <body><pre>
    <?php

    $connection =
    odbc_connect("t est","root","pa sswd");

    $query = odbc_exec($conn ection, "SELECT * FROM
    People");

    while ($row = odbc_fetch_row( $result))
    {
    for ($i=0; $i<odbc_num_fie lds($result);$i ++)
    echo $row[$i] . " ";

    echo "\n";
    }

    odbc_close($con nection);
    ?>
    </pre>
    </body>
    </html>
    I got an error msg
    Notice: Undefined variable: result in C:\Apache2\htdo cs\test3.php on
    line 14

    Warning: odbc_fetch_row( ): supplied argument is not a valid ODBC
    result resource in C:\Apache2\htdo cs\test3.php on line 14

    thank in adv

  • mattvenables

    #2
    Re: please help for beginner(php + ms access)

    that's because you never defined the variable $result that you are
    sending to the odbc_fetch_row function. try changing it to this:

    while ($row = odbc_fetch_row( $query))

    Comment

    • Tony

      #3
      Re: please help for beginner(php + ms access)


      "mattvenabl es" <mattvenables@g mail.com> wrote in message
      news:1118146126 .870262.314520@ g14g2000cwa.goo glegroups.com.. .[color=blue]
      > that's because you never defined the variable $result that you are
      > sending to the odbc_fetch_row function. try changing it to this:
      >
      > while ($row = odbc_fetch_row( $query))
      >[/color]

      or:

      $result = odbc_exec($conn ection, "SELECT * FROM
      People");

      since '$result' is used twice (it's also in the loop at "for ($i=0;
      $i<odbc_num_fie lds($result);$i ++)" )



      Comment

      Working...