Re: finding a file directly

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

    Re: finding a file directly

    On Thu, 17 Jul 2008 04:43:13 -0700 (PDT) wrote Captain Paralytic
    <paul_lautman@y ahoo.com>:
    >On 17 Jul, 08:55, Annette Block <wrote:
    >On Wed, 16 Jul 2008 23:59:16 +0100 wrote "Paul Lautman"
    ><paul.laut...@ btinternet.com> :
    >>
    >>
    >>
    >>
    >>
    >Annette Block wrote:
    >On Wed, 16 Jul 2008 20:32:31 +0100 wrote "Paul Lautman"
    ><paul.laut...@ btinternet.com> :
    >>
    >>>Annette Block wrote:
    >>>From a database of flowering plants (and ferns actually) visitors
    >>>can select a genus name and the narrow the search for species of
    >>>that genus. Then links are offered to the plants found.
    >>>The code is:
    >>>....
    >>>$sql = "SELECT nr, genus, species FROM flplants WHERE genus =
    >>>$gname"; $result = mysql_query($sq l) or die (mysql_error()) ;
    >>>$number = mysql_numrows($ result);
    >>>echo "You asked for $gname. ";
    >>>echo "We have the next $number of species to offer:<br>";
    >>>while($row = mysql_fetch_arr ay($result))
    >>>{
    >>>echo "<a href=\"plant.ph p?nr=$row[0]\">"."$gname "." ".
    >>>$row[2]."</a><br>";
    >>>}
    >>>....
    >>
    >>>So far, so good.
    >>>However, rather often there is only one row. Now I wonder if there
    >>>is a possiblity to guide the visitor in that case directly to the
    >>>file instead of clicking that one link.
    >>>I guess it should be something like
    >>>if ($number ==1)
    >>>{// code directly to plant.php with the right nr}
    >>>else
    >>>{//the above mentioned part from "You asked...}
    >>
    >>>Thank you
    >>>Annette Block
    >>
    >>>This isn't really a MySQL question.
    >>>Look at the php header() function with the Location: keyword
    >>
    >In that case: sorry for posting in the wrong group.
    >Annette
    >>
    >No problem, hope the answer helped.
    >>
    >I'm sorry to say no. Before calling header() a lot of traffic has been
    >sent. But thank you.
    >Annette- Hide quoted text -
    >>
    >- Show quoted text -
    >
    >I'm going to move this discussion across to comp.lang.php, which is
    >where it should be sitting.
    >
    >The way to overcome this problem is to use a buffer (see ob_start())
    >to hold the output. Then, if you find that you need to issue the
    >header call, you can use
    >while ob_end_clean();
    >to clear the buffer. No headers will have been issued then. If you
    >find that you need to output the existing traffic, use ob_end_flush().
    As I don't know how to move or to be moved I only can react here.
    As ob_start was new to me it took some experimenting to learn to
    handle it. I did not succeed. Besides it was all about a more
    user-friendly way avoiding an unnecessary click. I got the impression
    that by using ob_start etcetera the visitor is urged to keep a lot of
    content on his computer. The only reason to write this that I want to
    know if I'm right in this. Or is this all happening on the server?
  • Michael Fesser

    #2
    Re: finding a file directly

    ..oO(Annette Block <>)
    >On Thu, 17 Jul 2008 04:43:13 -0700 (PDT) wrote Captain Paralytic
    ><paul_lautman@ yahoo.com>:
    >
    >>The way to overcome this problem is to use a buffer (see ob_start())
    >>to hold the output. Then, if you find that you need to issue the
    >>header call, you can use
    >>while ob_end_clean();
    >>to clear the buffer. No headers will have been issued then. If you
    >>find that you need to output the existing traffic, use ob_end_flush().
    >
    >As I don't know how to move or to be moved I only can react here.
    >As ob_start was new to me it took some experimenting to learn to
    >handle it. I did not succeed. Besides it was all about a more
    >user-friendly way avoiding an unnecessary click. I got the impression
    >that by using ob_start etcetera the visitor is urged to keep a lot of
    >content on his computer. The only reason to write this that I want to
    >know if I'm right in this. Or is this all happening on the server?
    It's all happening on the server. The clients just receive the final
    HTML page, they won't notice how it was created. With or without output
    buffering - the result is the same.

    Anyway, using output buffering to "fix" the header problem is just a
    hack. It doesn't solve the real problem, which is caused by a rather
    suboptimal structure of your code. There's always a ways to do checks
    and redirects at the beginning of the script before any content output.
    So the correct way to solve this problem is to restructure your code.

    Micha

    Comment

    Working...