|
Posted by kenoli on 01/11/07 16:09
Thanks JW & Koncept --
I feel silly forgetting to open the session. Of course.
Thanks both for elaborating on passing the info via the URL. I had
actually tried it and it hadn't worked. Must have been a syntax error.
I have been finding that much of my struggle with php comes from not
working from the right perspective. I've appreciated your posts over
time, Koncept, for the assitance they have given me in "thinking php."
This is the stuff that doesn't get communicated via php.net (some in
the user comments) or even most books on php that I've read. I'm
starting to find that some of the more "advanced" books are actually
the most useful for learning php because they get into the headspace
more than the beginners books. It would be useful if more authors
understood how important the conceptual framework is rather than just
feeding code examples and explaining the mechanics.
Incidentally, there is a great book that really communicates the spirit
of Javascript in this way called "PPK on Javascript." Wish someone
would write womething similar on php.
Interested, Koncept????
--Kenoli
Janwillem Borleffs wrote:
> kenoli wrote:
> > // Send header
> > header("Content-type: image");
> >
>
> Invalid content-type, should be image/jpg, image/jpeg, image/gif or
> image/png.
>
> > The problem is that I want send an id to the echo_image.php file so I
> > can tell it which record to select the image from. When I set a
> > session variable in the first file and try to retrieve it in the
> > second file like this:
> >
> > <?php
> > $tid = $_SESSION['id'];
> >
>
> You are forgetting to start the session with session_start():
>
> session_start();
> $tid = $_SESSION['id'];
>
> Alternatively, you could also pass the ID through the image URL and read it
> from there:
>
> echo "<img src='echo_image.php?id=$id' ...>";
>
> Make sure that you check that the ID is actually a number.
>
>
> JW
[Back to original message]
|