problem with POST and if statements

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

  • GazK
    Guest replied
    Re: oops corrected post

    doh! thanks, that fixed that part of the problem.

    "Zac Hester" <news@planetzac .net> wrote in message
    news:3f18875c$3 @news.enetis.ne t...[color=blue]
    > "GazK" <tosspot@blueyo nder.co.uk> wrote in message
    > news:nG_Ra.3865 5$4c.5379@news-binary.blueyond er.co.uk...[color=green][color=darkred]
    > > > I have an image viewing page which resizes an image to a sensible[/color]
    > > sizebefore[color=darkred]
    > > > displaying. The user should then be able to choose "25% larger" or[/color][/color]
    > smaller[color=green][color=darkred]
    > > > and the resized image display. The problem I am getting with the code[/color]
    > > below[color=darkred]
    > > > is that whatever the POST variable value (and I have tested the value
    > > > changes correctly), the line marked with *** executes, ie the image[/color][/color][/color]
    gets[color=blue][color=green][color=darkred]
    > > > smaller. Am I missing some obvious subtlety with IF statements?
    > > >
    > > > Also, when the page reloads, it still displays the previous (ie[/color]
    > > non-resized)[color=darkred]
    > > > image, despite the fact that I have confirmed that the actual image in[/color][/color]
    > the[color=green][color=darkred]
    > > > directory has changed size. Is it the case that the image has been[/color][/color]
    > cached[color=green]
    > > by[color=darkred]
    > > > the browser? If so, how do I force a reload?
    > > >
    > > > TIA Gaz
    > > >
    > > > if(isset($_POST['submitScale'])) {
    > > > if ($_POST['scale'] = "25% smaller") {
    > > > resizeImageByPe rcent($thumbLoc ation, "resized", 75);***
    > > > }
    > > > else if ($_POST['scale'] = "25% larger") {
    > > > resizeImageByPe rcent($thumbLoc ation, "resized", 125);
    > > > }
    > > > else if ($_POST['scale'] = "full size") {
    > > > resizeImageByPe rcent($original Location, "resized", 100);
    > > > }
    > > > }[/color][/color]
    >
    > There's your first problem. Use "==" for comparison, and "=" for
    > assignment. Assignment returns the value assigned.
    >
    > -Zac
    >
    >[/color]


    Leave a comment:


  • Martin Wickman
    Guest replied
    Re: problem with POST and if statements

    In article <bfa4mt$cpete$1 @ID-194542.news.uni-berlin.de>, Leslie Hoare wrote:[color=blue]
    >
    > "Martin Wickman" <wizball@hotbre v.com> wrote in message
    > news:bf9sou$cfl o8$2@ID-156202.news.uni-berlin.de...
    >[color=green]
    >> Other than that, try a force reload of your browser to make sure you
    >> dont have any nasty cache problems.[/color]
    >
    > Kinda offtopic, but I didn't think POST requests were allowed to be cached
    > anyway.[/color]

    Well, try posting something and then reload. See, the browser keeps
    the stuff cached. About 'allowed' or not. I dont know, but I would
    guess that it's up to each browser to decide whether it should cache
    and not.

    Leave a comment:


  • Leslie Hoare
    Guest replied
    Re: problem with POST and if statements


    "Martin Wickman" <wizball@hotbre v.com> wrote in message
    news:bf9sou$cfl o8$2@ID-156202.news.uni-berlin.de...
    [color=blue]
    > Other than that, try a force reload of your browser to make sure you
    > dont have any nasty cache problems.[/color]

    Kinda offtopic, but I didn't think POST requests were allowed to be cached
    anyway.


    Leave a comment:


  • Zac Hester
    Guest replied
    Re: oops corrected post

    "GazK" <tosspot@blueyo nder.co.uk> wrote in message
    news:nG_Ra.3865 5$4c.5379@news-binary.blueyond er.co.uk...[color=blue][color=green]
    > > I have an image viewing page which resizes an image to a sensible[/color]
    > sizebefore[color=green]
    > > displaying. The user should then be able to choose "25% larger" or[/color][/color]
    smaller[color=blue][color=green]
    > > and the resized image display. The problem I am getting with the code[/color]
    > below[color=green]
    > > is that whatever the POST variable value (and I have tested the value
    > > changes correctly), the line marked with *** executes, ie the image gets
    > > smaller. Am I missing some obvious subtlety with IF statements?
    > >
    > > Also, when the page reloads, it still displays the previous (ie[/color]
    > non-resized)[color=green]
    > > image, despite the fact that I have confirmed that the actual image in[/color][/color]
    the[color=blue][color=green]
    > > directory has changed size. Is it the case that the image has been[/color][/color]
    cached[color=blue]
    > by[color=green]
    > > the browser? If so, how do I force a reload?
    > >
    > > TIA Gaz
    > >
    > > if(isset($_POST['submitScale'])) {
    > > if ($_POST['scale'] = "25% smaller") {
    > > resizeImageByPe rcent($thumbLoc ation, "resized", 75);***
    > > }
    > > else if ($_POST['scale'] = "25% larger") {
    > > resizeImageByPe rcent($thumbLoc ation, "resized", 125);
    > > }
    > > else if ($_POST['scale'] = "full size") {
    > > resizeImageByPe rcent($original Location, "resized", 100);
    > > }
    > > }[/color][/color]

    There's your first problem. Use "==" for comparison, and "=" for
    assignment. Assignment returns the value assigned.

    -Zac


    Leave a comment:


  • GazK
    Guest replied
    oops corrected post

    > I have an image viewing page which resizes an image to a sensible
    sizebefore[color=blue]
    > displaying. The user should then be able to choose "25% larger" or smaller
    > and the resized image display. The problem I am getting with the code[/color]
    below[color=blue]
    > is that whatever the POST variable value (and I have tested the value
    > changes correctly), the line marked with *** executes, ie the image gets
    > smaller. Am I missing some obvious subtlety with IF statements?
    >
    > Also, when the page reloads, it still displays the previous (ie[/color]
    non-resized)[color=blue]
    > image, despite the fact that I have confirmed that the actual image in the
    > directory has changed size. Is it the case that the image has been cached[/color]
    by[color=blue]
    > the browser? If so, how do I force a reload?
    >
    > TIA Gaz
    >
    > if(isset($_POST['submitScale'])) {
    > if ($_POST['scale'] = "25% smaller") {
    > resizeImageByPe rcent($thumbLoc ation, "resized", 75);***
    > }
    > else if ($_POST['scale'] = "25% larger") {
    > resizeImageByPe rcent($thumbLoc ation, "resized", 125);
    > }
    > else if ($_POST['scale'] = "full size") {
    > resizeImageByPe rcent($original Location, "resized", 100);
    > }
    > }
    >
    > ....blah blah blah some code
    >
    > <form action="imagevi ew.php3?image_i d=<?echo $row["image_id"]?>"
    > method="POST">
    > Make this image&nbsp;<sel ect name="scale">
    > <option>25% smaller
    > <option>25% larger
    > <option>full size
    > </select>
    > <input type="submit" name="submitSca le" value="Go!">
    > </form>
    >
    >[/color]


    Leave a comment:


  • Zac Hester
    Guest replied
    Re: problem with POST and if statements

    "GazK" <tosspot@blueyo nder.co.uk> wrote in message
    news:mkZRa.3718 2$4c.518@news-binary.blueyond er.co.uk...[color=blue]
    > I have an image viewing page which resizes an image to a sensible[/color]
    sizebefore[color=blue]
    > displaying. The user should then be able to choose "25% larger" or smaller
    > and the resized image display. The problem I am getting with the code[/color]
    below[color=blue]
    > is that whatever the POST variable value (and I have tested the value
    > changes correctly), the line marked with *** executes, ie the image gets
    > smaller. Am I missing some obvious subtlety with IF statements?
    >
    > Also, when the page reloads, it still displays the previous (ie[/color]
    non-resized)[color=blue]
    > image, despite the fact that I have confirmed that the actual image in the
    > directory has changed size. Is it the case that the image has been cached[/color]
    by[color=blue]
    > the browser? If so, how do I force a reload?[/color]

    This is how I tell the browser not to cache something:

    header('Expires : Mon, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    header('Cache-Control: no-cache, must-revalidate');
    header('Pragma: no-cache');

    I think I got this out of the PHP manual when looking up how to use the
    header() function. Oh, if you're serving images off of the file system (and
    not through a database or other dynamic means), I've found it works to read
    the file in using fread() and send it to the client with the appropriate
    "Content-Type" header. I created a bandwidth meter in PHP that used an
    image file to test the transfer rate between a client and my server. It
    seemed that the easiest way to make sure the image was never cached by the
    browser was to use PHP (and the non-caching headers) to send the file
    manually. (I'm sure there's an Apache work-around, though.)

    By the way, are you changing the "width" and "height" attributes of your
    image tag on the front end?

    HTH,
    Zac


    Leave a comment:


  • GazK
    Guest started a topic problem with POST and if statements

    problem with POST and if statements

    I have an image viewing page which resizes an image to a sensible sizebefore
    displaying. The user should then be able to choose "25% larger" or smaller
    and the resized image display. The problem I am getting with the code below
    is that whatever the POST variable value (and I have tested the value
    changes correctly), the line marked with *** executes, ie the image gets
    smaller. Am I missing some obvious subtlety with IF statements?

    Also, when the page reloads, it still displays the previous (ie non-resized)
    image, despite the fact that I have confirmed that the actual image in the
    directory has changed size. Is it the case that the image has been cached by
    the browser? If so, how do I force a reload?

    TIA Gaz

    if(isset($_POST['submitScale'])) {
    if ($_POST['scale'] = "25% smaller") {
    resizeImageByPe rcent($thumbLoc ation, "resized", 75);
    }
    else if ($_POST['scale'] = "25% larger") {
    resizeImageByPe rcent($thumbLoc ation, "resized", 125);
    }
    else if ($_POST['scale'] = "full size") {
    resizeImageByPe rcent($original Location, "resized", 100);
    }
    }

    .....blah blah blah some code

    <form action="imagevi ew.php3?image_i d=<?echo $row["image_id"]?>"
    method="POST">
    Make this image&nbsp;<sel ect name="scale">
    <option>25% smaller
    <option>25% larger
    <option>full size
    </select>
    <input type="submit" name="submitSca le" value="Go!">
    </form>


Working...