img=1 in the url gives no result on my server

<a href="pricing.php?img=1&<?php include 'lng.inc'; ?>"><span class="item">

this above menu link gives page pricing.php with append to url img=1

<img src="images/pricing/<?php echo ($img) ;?>.jpg" alt="img" /> </div>

but arriving on the pricing.php page here the img=1 does not get parsed and thats why the img will not show. Why?
the url that gets parsed is .jpg not 1.jpg, why?
only on my server this does not work, myserver runs php 5.2 it works on my friends server, with php version unknown. Does anyone know why my server cannot do this correctly? Anything obvious, i get no errors…

cheers, David

where is your GET code??

[php]
$img = $_GET[‘img’];
img
[/php]

although you should probably check if its set…
[php]
if(isset($_GET[‘img’])) {
img
}else{
//do somthing else if not set
}
[/php]

Hi thanks for your help,

I thought it needs to construct a filename from the menu url &img=1, in this case 1.jpg
so it opens the image, that’s how it works on the other server, I cannot find any GET .

check this out, this is the server where it works: andarilhohostel.com/testphp

I just took 2 lines of code that I thought where doing the job, and indeed they were, but now how do I get it
to work on another server.

but nevertheless adding [php]$img = $_GET[‘img’];[/php] worked, maybe the GET is somewhere hidden on the other server, I have no clue.

thanks again!

so now we use this;

[php]img [/php]

and it works. The 1 is added to .jpg,]

$_GET is not hidden

$_GET[‘img’] is simply grabbing the 1 set in the URL ?img=1
so if your URL is

www.somewebsite.com/test.php?img=1&hello=2&test=hello

$_GET[‘img’]=1
$_GET[‘hello’]=2
$_GET[‘test’]=hello

get it??

now, if you used a form with the method of POST… the info is passed but NOT in the URL

$_POST[‘img’]=1

hope this helps! have fun!

it works on one server where i don’t see any GET anywhere in the code,
on my server I added GET and it works, without it won’t work.

but thanks to you it works on my server… now we can forget about why or where the GET comes from or why it actually works without, or we can try to find out why out ov curiosity.

both work for me…

I totally GET what youmean, the img=1 in the url gives the code on the next page a number to construct an image url in this case 1.jpg, from there a gallery thumbnail array takes over…

$img needs to specified in a statement, $ is the sign for var in php I presume? sounds logical.
OK but why can it work on another server where I gotr the code from. How can there be no establishing the var $img and it still works? I cannot find it anywhere.

this is the old server where I have to website from, They want me to host it on my server.

For test i put only the relevant code in 2 separate php files, chek it.
index.php [php]

  • link
  • [/php]
    pricing.php [php]
    img
    [/php]

    It works!! no GET for the $img anywhere. HOW can this be?

    http://www.andarilhohostel.com/testphp/

    On my server this must have GET to be able to work, just curious why not need GET on the old server

    Clear your browser cache, close it reopen it and try again…

    Unless there is some other place that the variable is being set! Or, unless you are storing it in the wrong folder.

    Sorry what do you mean? Can You please explain why and what so I understand what the process behind your idea is. It’s the same folder structure, I can see on my server the number 1 is not correctly added to the url.
    so I end up with .jpg in the url

    on the old server the image url is correctly constructed with 1.jpg

    after adding $_GET it also works on my server, so just can’t understand why it works on the old server without GET

    I have looked everywhere for where the variable is set, it seems automagically is set.
    I even took only the relevant code out and placed it seperately in 2 php files ina separate folder.
    The link is http://www.andarilhohostel.com/testphp/… it WORKS,

    And, you looked at the code in the pricing.php to see if it is exactly the same as yours?

    Also, it could be as simple as URL rewriting. Most large sites have some sort of URL rewriting to make sure that the display starts with some number. That would be hidden inside the .htacess file in that folder or the root folder or it can be done inside of PHP.ini files. Inside that folder or the root. Check out those two files…

    Other than that I do not get it!

    I checked for that on both servers .htaccess is not existend on the server that runs it fine without GET.
    I replaced .htaccess with xxxxhtaccess disabeling it on my server, but it did not make it work without GET
    Not that it matters, It works!! Just baffeled why it works without GET on the old server
    PHP.ini is not available to me, but I just remembered on my server the img=1 is in the url, but in the html
    the url becomes .jpg not 1.jpg.
    So that rules out url rewriting since the URL is correct, missing is GET needs to get the img=1 parameter from the url and plant it in front of the .jpg

    <img src="images/pricing/<?php echo ($img) ;?>.jpg" alt="img" />

    just this is needed to show 1.jpg on the old server

    ( that is with img=1 in the page URL ofcourse)

    I need this code on my server to show 1.jpg:

    <?php $img = $_GET['img']; echo ($img) ;?>.jpg" alt="img" />

    wich seems more logic to me

    <img src="images/pricing/<?php $img = $_GET['img']; echo ($img) ;?>.jpg" alt="img" />

    my mistake i mean this is needed on my server

    Sponsor our Newsletter | Privacy Policy | Terms of Service