1

I'm trying to pass the path of an image ['guest'] from one page to another using a link. (I'm storing URLs of images in database) Can't seem to get the image to display, which is a bigger image of 'url'. I'm doing it this way so that I can have a larger image displayed in the target page (does_this_work.php) plus adding some other bits on the page too.

I'm still learning and can;t seem to see what I'm doing wrong. Any help appreciated,

<?php 

$host=""; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name=""; // Table name 

// Connect to server and select databse.
mysql_connect($host, $username, $password)or die("cannot connect"); 
mysql_select_db($db_name) or die("cannot select DB");


$photo=mysql_query("SELECT * FROM `images` ORDER BY (ID = 11) DESC, RAND() LIMIT 7");

while($get_photo=mysql_fetch_array($photo)){ ?>

<div style="width:300px;">


<a href="does_this_work.php?big_image=$get_photo['guest']>" target=""><img src="<?     
echo $get_photo['url']; ?>" title="">


 </div>

 <? } ?>

I then use the following code to try and display the array data in the target file

<?php

echo "this is the page where you get a larger picture of image on previous page, plus     
further info";

$big_image = $_GET['guest'];

echo $big_image;

?>
1
  • 1
    while there are many other things wrong with this: $_GET['big_image'] not $_GET['guest'] Commented Feb 29, 2012 at 22:11

3 Answers 3

1

You're missing an opening tag in here (And a closing semi colon, but that's not as problematic here):

<a href="does_this_work.php?big_image=$get_photo['guest'] ?>"

Change to:

<a href="does_this_work.php?big_image=<?= $get_photo['guest']; ?>"
Sign up to request clarification or add additional context in comments.

Comments

0

There are several errors in your code. First of all, this is how you use $_GET and $_POST:

ex. site.php?argument=value

To retrieve the value of argument, you need this code in site.php:

//The variable must not necessarily be $value
$value = $_GET['argument'];
//Alt.
$value = $_POST['argument'];

Secondly (like the other answers tell you) you are missing a php-tag here:

<a href="does_this_work.php?big_image=$get_photo['guest']>" target=""><img src="<? echo $get_photo['url']; ?>" title="">

Instead it should be:

<a href="does_this_work.php?big_image=<?php echo $get_photo['guest']; ?>" target=""><img src="<?php echo $get_photo['url']; ?>" title="">

Now, in order to make that compatible with your second code, you need to change the argument sent to guest like this:

<a href="does_this_work.php?guest=<?php echo $get_photo['guest']; ?>" target=""><img src="<?php echo $get_photo['url']; ?>" title="">

OR change the $_GET['guest']; to $_GET['big_image'];

I think I got it all right..

5 Comments

thanks for that. Have made changes but still not getting the image displayed on does_this_work.php. Have tried putting
Does $big_image; include the <img>-tag? If not, have you added it to the echo? (Talking about your second script now.)
thanks for that. Can't tell you how long I've been on that for!cheers
Yeah, adding the image tag displayed the image. Cheers
Hehe, no problems. Glad to help!
0
<a href="does_this_work.php?big_image=$get_photo['guest'] ?>" target=""><img src="<?     
echo $get_photo['url']; ?>" title="">

You are missing your php starting tags. This should read:

<a href="does_this_work.php?big_image=<? $get_photo['guest'] ?>" target=""><img src="<?     
echo $get_photo['url']; ?>" title="">

3 Comments

<? $get_photo['guest'] ?>, what do you expect that to 'do'?
<?= Oops. Yeah that usually helps.
Cheers for your help on that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.