Variable problem. I think.

G

Guest

Guest
I don't know too much about PHP, but I CAN do a few things after staring at code for hours. I have a problem I don't even know if I can explain it right.

I think it has to do with passing variables. OKay here we go:

I have a main page and an 'Image Viewer' page. So when I want to link to a picture I simply wrtie this:
Code:
<a href="images/index.php?image=imagename.jpg">
where on the image page I simply have:

Code:
<image src=<? print $image; ?> border=0>

It works just fine...

But NOW I want to have a little description of each image at the bottom of each picture with out writing something like this:

Code:
<a href=images/index.php?image=imagename.jpg?desc=A picture of my house>

which I couldn;t get to work anyway when I tried it.

So Iput a little script at the top of the image/index.php page that looks like this:

Code:
<?php
//--- default desc
$desc="No description available";

//--- read image data
$buffer=file("description.txt");

//--- convert to array
$data= array();
foreach ( $buffer as $line ){
	$data[]=explode(";",$line);
}

$found=false;
$i=0;
while( $i<count($data) and !$found ){
	if ( $id== $data[$i][0] ){
		$desc=$data[$i][1];
		$found=true;
	}
	$i++;
}
?>

the description.txt is just a simple flat textfile that reads

Code:
1;description of image goes here

So it pulls the descritpion from the txt file.

OKay it works with
Code:
<a href="images/index.php?image=imagename.jpg">
and
Code:
<a href="images/index.php?id=1">

But it won't work with both like:
Code:
<a href="images/index.php?image=imagename.jpg?id=1">

Did I explain it okay? Does anyone know what I should do? Feel free to email me if you want more info.
 
Hi!

If you so strong why you have stupid mistakes?

It's not PHP error it's yours fault.

If you see carefully at URL string after query some search web site like http://www.Google.com or some else search engine or else you see next:

google.com/imghp?hl=ru&ie=UTF-8

How about & - link between query?

you wrote:

OKay it works with
Code:
<a href="images/index.php?image=imagename.jpg">
and
Code:
<a href="images/index.php?id=1">

But it won't work with both like:
Code:
<a href="images/index.php?image=imagename.jpg?id=1">

Did I explain it okay? Does anyone know what I should do? Feel free to email me if you want more info.

need:
Code:
<a href="images/index.php?image=imagename.jpg?&id=1">

whats all....

P.S.
I'm too long time reading and rereading your message and self can't understand what wrong in yours code....
 
Back
Top