Help with oci_result()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    Help with oci_result()

    Hello everyone,

    I am trying to get the result of a query in a php variable
    I wander what's wrong with this code because I don't get a value in $val, I
    am sure my select is correct as it returns a value in SQL worksheet for
    instance.

    <?php

    $val = 'test';

    print "value = $val <br>";

    $con=oci_connec t("dave","test" ,$bd_name);


    $sql="select fruit_name from fruits where fruit_id=2";

    $stmt=oci_parse ($con,$sql);

    oci_execute($st mt, oci_default);

    oci_fetch($stmt );

    $val = oci_result($stm t,0);

    oci_free_statem ent($stmt);

    print "value = $val ";

    ?>


  • seajay

    #2
    Re: Help with oci_result()

    hello,

    Try to place the name of the field you are trying to get such as
    $val = oci_result($stm t,"fruit_name") ;

    You can also check the following page for more details
    Returns the next row from a query as an associative or numeric array


    Comment

    • Mladen Gogala

      #3
      Re: Help with oci_result()

      On Sun, 09 Apr 2006 13:42:34 -0700, seajay wrote:
      [color=blue]
      > hello,
      >
      > Try to place the name of the field you are trying to get such as
      > $val = oci_result($stm t,"fruit_name") ;
      >
      > You can also check the following page for more details
      > http://www.php.net/manual/en/functio...etch-array.php[/color]

      That will work. Also, oci_result starts counting columns with 1, not with
      0. I responded to this on comp.databases. oracle.server.

      --


      Comment

      Working...