session registering a row from a mysql search

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

    session registering a row from a mysql search

    Hi,
    I am having trouble registering a row from a mysql query

    so far I have the mysql part working :

    while ( $val = mysql_fetch_arr ay( $result ))
    {
    print("<tr><td> $val[0]</td>
    <td>$val[1]</td>
    <td>$val[2]</td>
    <td>$val[3]</td>
    <td>$val[4]</td>
    </tr>\n");
    }

    But, getting these fields into an array for which to register these is a bit
    of a problem
    any help would be appreciated, as soon as I do the fetch and priint them out
    these fields seem lost to the world.

    Thanks
    Bob
    Thanks


  • Geoff Berrow

    #2
    Re: session registering a row from a mysql search

    I noticed that Message-ID: <zmNoc.21082$KS 1.325948@nasal. pacific.net.au>
    from Bob contained the following:
    [color=blue]
    >
    >while ( $val = mysql_fetch_arr ay( $result ))
    > {
    > print("<tr><td> $val[0]</td>
    > <td>$val[1]</td>
    > <td>$val[2]</td>
    > <td>$val[3]</td>
    > <td>$val[4]</td>
    > </tr>\n");
    >}[/color]

    try $val['fieldname']

    --
    Geoff Berrow (put thecat out to email)
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • Pedro Graca

      #3
      Re: session registering a row from a mysql search

      Bob wrote:[color=blue]
      > I am having trouble registering a row from a mysql query[/color]

      What do you mean with "registerin g"?
      [color=blue]
      > so far I have the mysql part working :
      >
      > while ( $val = mysql_fetch_arr ay( $result ))
      > {
      > print("<tr><td> $val[0]</td>
      > <td>$val[1]</td>
      > <td>$val[2]</td>
      > <td>$val[3]</td>
      > <td>$val[4]</td>
      > </tr>\n");
      > }[/color]

      OK, this will print as many rows as the number of records returned from
      the database.
      [color=blue]
      > But, getting these fields into an array for which to register these is a bit
      > of a problem
      > any help would be appreciated, as soon as I do the fetch and priint them out
      > these fields seem lost to the world.[/color]

      Are you, by any chance, trying to access $val /outside/ the while loop?

      <?php
      while ($val = mysql_fetch_arr ay($result)) {
      print("...");
      $valid_data_arr ay = array($val[0], $val[1], $val[2]); // ok here
      }
      $invalid_data_a rray = array($val[0], $val[1], $val[2]); // wrong!
      ?>



      You might want to increase the level of error_reporting in your scripts
      to have php itself tell you about the use of uninitialized variables and
      a few other mistakes in coding that it can catch.
      Put these lines at the very beginning of your scripts

      <?php
      ini_set('error_ reporting', E_ALL);
      ini_set('displa y_errors', '1');
      ?>



      HTH
      --
      USENET would be a better place if everybody read: : mail address :
      http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
      http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
      http://www.expita.com/nomime.html : to 10K bytes :

      Comment

      • Bob

        #4
        Re: session registering a row from a mysql search


        "Pedro Graca" <hexkid@hotpop. com> wrote in message
        news:2ght35F310 8vU2@uni-berlin.de...[color=blue]
        > Bob wrote:[color=green]
        > > I am having trouble registering a row from a mysql query[/color]
        >
        > What do you mean with "registerin g"?
        >[color=green]
        > > so far I have the mysql part working :
        > >
        > > while ( $val = mysql_fetch_arr ay( $result ))
        > > {
        > > print("<tr><td> $val[0]</td>
        > > <td>$val[1]</td>
        > > <td>$val[2]</td>
        > > <td>$val[3]</td>
        > > <td>$val[4]</td>
        > > </tr>\n");
        > > }[/color]
        >
        > OK, this will print as many rows as the number of records returned from
        > the database.
        >[color=green]
        > > But, getting these fields into an array for which to register these is a[/color][/color]
        bit[color=blue][color=green]
        > > of a problem
        > > any help would be appreciated, as soon as I do the fetch and priint them[/color][/color]
        out[color=blue][color=green]
        > > these fields seem lost to the world.[/color]
        >
        > Are you, by any chance, trying to access $val /outside/ the while loop?
        >
        > <?php
        > while ($val = mysql_fetch_arr ay($result)) {
        > print("...");
        > $valid_data_arr ay = array($val[0], $val[1], $val[2]); // ok here
        > }
        > $invalid_data_a rray = array($val[0], $val[1], $val[2]); // wrong!
        > ?>
        >
        >
        >
        > You might want to increase the level of error_reporting in your scripts
        > to have php itself tell you about the use of uninitialized variables and
        > a few other mistakes in coding that it can catch.
        > Put these lines at the very beginning of your scripts
        >
        > <?php
        > ini_set('error_ reporting', E_ALL);
        > ini_set('displa y_errors', '1');
        > ?>[/color]

        thanks for your reply

        i got around it quite simply :
        (hides head in shame)

        print("<tr><td> $val[0]</td>
        <td>$val[1]</td>
        <td>$val[2]</td>
        <td>$val[3]</td>
        <td>$val[4]</td>
        </tr>\n");
        $prod_id = $val[0];
        $prod_name = $val[1];
        $price = $val[2];
        $quantity = $val[3];
        $stock = $val[4];

        then registered the variables i assigned val[n] too.
        total newbie me.


        Comment

        • Bob

          #5
          Re: session registering a row from a mysql search


          "Pedro Graca" <hexkid@hotpop. com> wrote in message
          news:2ght35F310 8vU2@uni-berlin.de...[color=blue]
          > Bob wrote:[color=green]
          > > I am having trouble registering a row from a mysql query[/color]
          >
          > What do you mean with "registerin g"?
          >[color=green]
          > > so far I have the mysql part working :
          > >
          > > while ( $val = mysql_fetch_arr ay( $result ))
          > > {
          > > print("<tr><td> $val[0]</td>
          > > <td>$val[1]</td>
          > > <td>$val[2]</td>
          > > <td>$val[3]</td>
          > > <td>$val[4]</td>
          > > </tr>\n");
          > > }[/color]
          >
          > OK, this will print as many rows as the number of records returned from
          > the database.
          >[color=green]
          > > But, getting these fields into an array for which to register these is a[/color][/color]
          bit[color=blue][color=green]
          > > of a problem
          > > any help would be appreciated, as soon as I do the fetch and priint them[/color][/color]
          out[color=blue][color=green]
          > > these fields seem lost to the world.[/color]
          >
          > Are you, by any chance, trying to access $val /outside/ the while loop?
          >
          > <?php
          > while ($val = mysql_fetch_arr ay($result)) {
          > print("...");
          > $valid_data_arr ay = array($val[0], $val[1], $val[2]); // ok here
          > }
          > $invalid_data_a rray = array($val[0], $val[1], $val[2]); // wrong!
          > ?>[/color]

          doh !
          basic tenets of structured programming.


          Comment

          Working...