I have php 5 installed for now, but I’m finding that the javascript pop up window is no longer transferring the data to the pop up window. It is supposed to display a larger image than the thumbnail upon click. I am not sure if this broke in php5 or not, but I’m trying to repair some older sites.What happens is that the pop up window opens, but the data is not transferred to it. This is the code in the catalog page:
Where pictures is the field for the larger image the thumbnail is what it says. The popup window code is below. Would appreciate if you can help me figure out what is no longer allowed. It used to work just fine.
Presuming that the second section of code is your show_image.php, is the code to extract $img from the URL somewhere else, and is it working correctly?
I’ve a vague idea that someone mentioned that very early versions of PHP would automatically parse URL variables into internal variables of the same name, but I can’t find a reference to it, I’d always expect to see it extracted from the appropriate superglobal array, $_GET in this case.
Can you show exactly what you did? Note that it should be $_GET['img'] - remember, $img does not exist in show_image.php unless you create it somewhere.
ETA - is the image URL-friendly when it is stored?
Yes, but not in the completely separate show_image.php script, where you are trying to use it. You’re passing the value of that variable through in the URL, but not the name of it. In this section of code:
you are assigning it a value immediately after you echo the value as part of the URL, but only within this specific script. In fact if this is a catalogue of images, perhaps this bit of code is inside a loop, which means that the value of $img is changed for each iteration of the loop.
That’s not the correct syntax. Have a look at the post above. In order for that line to work, you first have to have a value in $img. As you said that’s the first line of the script, there can’t be any lines before it to have assigned $img any kind of value, so that equates to $_GET[''], which might give an undefined index error.
I appreciate the help. The frustrating thing is that it used to work just fine. So I’m not sure what I need to add to get the variable to pass through. It is in a loop of catalog images, so it has to post the current image value on click. However, if I place the GET after the first line, the $img variable is already assumed, which is no longer working. It isn’t being passed.
What do you suggest? The other thing I thought of might be a complete php hover solution, if that is possible. But couldn’t find an example that would eliminate the need for a pop up. But if it relies on scripts, I might have the same issue.
As in my earlier post, you need to get the value from the URL:
<?php $id1 = basename($_GET['img'], '.gif');
I did mention that I’ve a vague idea that (very) old versions of PHP didn’t need this, that they would automatically parse out parameters into variables. I tried a bit of a search to see if I’d imagined it, but I didn’t get very far. That would certainly explain why it used to work, though.
That suggests that there is nothing in your $row_viewall['pictures'] variable, unless the fact that it’s an onclick handler rather than a “normal” a href URL that is blocking it.
If you right-click and view source in your browser, has it put a value that you expect into the link?
OK. Can you modify the start of your show_image.php file to read like this, then show the results when you click on the link please?
<?php
var_dump($_GET);
exit;
Or, if you haven’t changed the use of $img further down the page to use the $_GET array member, you could just add this line:
<?php
$img = $_GET['img']; // this is the new line
$id1 = basename($img, '.gif'); // and this is your old first line, carry on from here
but I doubt that would help, as all the other data (title, description) would have been populated after you changed the start of the script as per post 12. As you said that hadn’t worked, I presumed the title and so on was still blank at that point.
PHP has no idea that the information has come from JavaScript. It must be that some old version would automatically parse that array into discrete variables. I’ve had another search as I have an idea that it’s been mentioned on here, but I can’t easily find it.