PHP Won't load variables correctly
Posted: Thu May 13, 2004 3:45 am
Ok, so I have written a script that creates basically two HTML pages. First, it creates a page for thumbnailed images. Then, when a thumbnailed image is clicked, the larger image page is created. The script is set up in this order:
-- Use the $_GET expression to get the variable from the header.
-- Create the thumbnail page
-- Create the large image page
-- Create the check() function
-- Create the switch with variables
Here's the code... all 300 lines of it.
Now, you can check it out here:
My Image Loader
What should happen, is when the thumbnail is clicked, a new window pops-up and the title is defined in the echo_image() tag. Also the comment is defined there too. Problem is, is that neither show up. If you view the source code, the variables aren't passed so the HTML looks like this:
How can I fix it?
Another problem (smaller yet easier) is the stop() function that I define. I call it so that the script stops there. Otherwise it creates two thumbnail pages, and a thumbnail page after the large image. So my question is:
What function can I call that will stop the script where I want it that won't cause it to error like it is now?
Thanks for the help you guys can offer.
~Brett Patterson
-- Use the $_GET expression to get the variable from the header.
-- Create the thumbnail page
-- Create the large image page
-- Create the check() function
-- Create the switch with variables
Here's the code... all 300 lines of it.
Code: Select all
<?php
$image_num = $_GET['img'];
if($image_num != ""){
echo_image($title,$image_num,$caption);
}else{
echo_thumbnail();
}
stop();
################################################################
# #
# FUNCTION TO CREATE THE THUMBNAIL PAGE #
# #
################################################################
function echo_thumbnail() {
#########################################################
# #
# DEFINE VARIABLES TO BE USED WITHIN THE FUNCTION #
# #
#########################################################
$num_of_images = '52';
$title = 'Halloweenfest - 2003: October 31, 2003 - New Jersey';
$vlink = '#009999';
$alink = "#0066CC";
$link = "#006666";
$text = "#FFFFFF";
$bgColor = "#006699";
$month_image_path = './images/thumbs/2003halloweenFest';
$up_one_level = 'http://userpages.umbc.edu/~brett2/phpimageLoader/imageLoader.php';
$month_path = './imageLoader?';
############################################
# DONE DEFINING FUNCTIONAL VARIABLES #
############################################
echo('<HTML><TITLE>'.$title.'</TITLE>');
echo('<BODY bgcolor="'.$bgColor.'" " vlink="'.$vlink.'" alink="'.$alink.'" link="'.$link.'">');
echo('<P align="center"><A href="'.$up_one_level.'"><FONT face="Webdings" color="'.$text.'">l</FONT></A></P>');
$x = 1;
echo('<P align="center">');
for($x =1; $x <= $num_of_images; $x++ ) {
echo('<A href="'.$month_path.'img='.check($x).'" target="_blank">');
echo('<IMG border="0" src="'.$month_image_path.check($x).'.jpg"></A>');
echo(' ');
if( $x%5 == 0) {
echo('</BR>');
}
}
echo('</P>');
echo('</BODY>');
echo('</HTML>');
}
################################################################
# #
# FUNCTION TO CREATE THE LARGE IMAGES ON THUMBNAIL CLICK #
# #
################################################################
function echo_image($title,$image_num,$caption) {
#########################################################
# #
# DEFINE VARIABLES TO BE USED WITHIN THE FUNCTION #
# #
#########################################################
$num_of_images = '52';
$vlink = '#009999';
$alink = "#0066CC";
$link = "#006666";
$text = "#FFFFFF";
$bgColor = "#006699";
$month_image_path = './images/2003halloweenFest';
$up_one_level = 'http://userpages.umbc.edu/~brett2/phpimageLoader/imageLoader.php';
$month_path = './imagesLoader.php?';
$month_home = './imageLoader.php';
############################################
# DONE DEFINING FUNCTIONAL VARIABLES #
############################################
echo("<HTML><HEAD><TITLE>".$title."</TITLE>");
echo('<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>');
echo('<BODY vLink='.$vlink.' aLink='.$alink.' link='.$link.' bgColor='.$bgColor.'>');
echo('<P align=center><IMG src="'.$month_image_path.$image_num.'.jpg" border=0></P>');
echo('<P align=center><br><FONT color='.$text.'>'.$caption.'</FONT></P>');
echo('<P align=center>');
if($image_num > 1)
{
$img_num_L = $image_num - 1;
echo('<A href="'.$month_path.'img='.$img_num_L.'">');
echo('<FONT color='.$llink.'>Backwards</FONT></A>');
}
echo(' ');
echo('<A href="'.$month_home.'"><FONT face=Webdings color='.$text.'>l</FONT></FONT></A>');
echo(' ');
if($image_num < $number_of_images)
{
$img_num_U = $image_num + 1;
echo('<A href="'.$month_path.'img='.$img_num_U.'">');
echo('<FONT color='.$llink.'>Forwards</FONT></A>');
}
echo('</P></BODY></HTML>');
}
###############################################################################
function check($num)
{
if($num < 10){
return '0'.$num;
}
return $num;
}
#######################################################################
# #
# FUNCTION TO DEFINE THE TITLE, AND COMMENT OF THE LARGE IMAGES #
# #
#######################################################################
$img *= 1;
switch($img){
case 1:
echo_image("HalloweenFest 2003 - Stage",$img,"I was here");
break;
case 2:
echo_image("HalloweenFest 2003 - The Grounds",$img,"The Grounds as viewed from the stage area");
break;
case 3:
echo_image("HalloweenFest 2003 - Activities",$img,"Blow-Up Activities for the kids");
break;
case 4:
echo_image("HalloweenFest 2003 - Group Shot 1",$img,"The Group... Need I say More?");
break;
case 5:
echo_image("HalloweenFest 2003 - Group Shot 2",$img,"Hmm... A closer shot? I am surprised the camera did not break");
break;
case 6:
echo_image("HalloweenFest 2003 - Group Shot 3",$img,"Well, we're alive because we are standing.");
break;
case 7:
echo_image("HalloweenFest 2003 - Group Shot 4",$img,"And closer yet again...");
break;
case 8:
echo_image("HalloweenFest 2003 - Hay Bail Pumpkin Dryer",$img,"Boo!!! I see YOU!!!");
break;
case 9:
echo_image("HalloweenFest 2003 - Signs",$img,"Happy Halloween Everybody!!!");
break;
case 10:
echo_image("HalloweenFest 2003 - Halloween Characters",$img,"I see the monster... but who is the guy in the bluish/purple?");
break;
case 11:
echo_image("HalloweenFest 2003 - More Characters",$img,"I Figured it out... He's Frankenstein!!!");
break;
case 12:
echo_image("HalloweenFest 2003 - Pin the Something On The Something",$img,"I wonder who is in the blind-fold....?");
break;
case 13:
echo_image("HalloweenFest 2003 - Pin the Nose on the Pumpkin!!",$img,"Yup... It's me.");
break;
case 14:
echo_image("HalloweenFest 2003 - Pin the Nose on the Pumpkin!!",$img,"Wait that's not me!!");
break;
case 15:
echo_image("HalloweenFest 2003 - Pin the Nose on the Pumpkin!!",$img,"Look at how close she got it!!");
break;
case 16:
echo_image("HalloweenFest 2003 - Tale As Old As Time...",$img,"Beauty and the Beast... but I'm not in the picture");
break;
case 17:
echo_image("HalloweenFest 2003 - Scratch It... Scratch, Scratch It!",$img,"The Beast must have fleas....");
break;
case 18:
echo_image("HalloweenFest 2003 - WTF MATE?!?!?!?!",$img,"I thought this was scary? AHH!! It's a Christmas tree!!! It's going to Eat ME!!!!");
break;
case 19:
echo_image("HalloweenFest 2003 - WTF MATE?!?!?!?!",$img,"Oh wait... It's just a kid");
break;
case 20:
echo_image("HalloweenFest 2003 - It's an Elephant!",$img,"Did it swallow a treasure chest?");
break;
case 21:
echo_image("HalloweenFest 2003 - State Worker in Training",$img,"But Mom... I don't wanna!!");
break;
case 22:
echo_image("HalloweenFest 2003 - Harry Potter",$img,"Is this a big enough smile?");
break;
case 23:
echo_image("HalloweenFest 2003 - Interesting Costumes",$img,"Need a little help on this one....");
break;
case 24:
echo_image("HalloweenFest 2003 - Cinderelly Cinderelly!!",$img,"Where's Gus Gus?");
break;
case 25:
echo_image("HalloweenFest 2003 - Lions & Tigers & Bears!!",$img,"If I. Were King. Of the FORRREST!!");
break;
case 27:
echo_image("HalloweenFest 2003 - Some like to go that way -->",$img,"The sum of the square of any hypotenuse....");
break;
case 28:
echo_image("HalloweenFest 2003 - Look at the baby!!",$img,"Do you really think the kid is having a good time?");
break;
case 29:
echo_image("HalloweenFest 2003 - mmmm.... Earth Meat",$img,"We are from planet Zoird. We come to smile at you....");
break;
case 30:
echo_image("HalloweenFest 2003 - Excuse Me!!",$img,"Where has my broom-stick gone? I can't fly without the broom-stick!!");
break;
case 31:
echo_image("HalloweenFest 2003 - lalalalalala!!",$img,"I don't want to be in the parade. I'll just stand here!");
break;
case 32:
echo_image("HalloweenFest 2003 - Who Lives In a Pineapple Under the sea!!",$img,"Some huge fish guy!!!");
break;
case 33:
echo_image("HalloweenFest 2003 - And who would I do?",$img,"Anyone... age 13 and up!!!");
break;
case 34:
echo_image("HalloweenFest 2003 - What in the world?!?!?!",$img,"I don't get what she is...");
break;
case 35:
echo_image("HalloweenFest 2003 - Back to the beauty",$img,"And there's the BEAST!!!");
break;
case 36:
echo_image("HalloweenFest 2003 - I'M FAT!!!",$img,"Boooow oup!!!");
break;
case 37:
echo_image("HalloweenFest 2003 - Uh Oh!!!",$img,"My Thong is ridin up on me!!!");
break;
case 38:
echo_image("HalloweenFest 2003 - WILMA!!!!",$img,"Let's 'drive' somewhere");
break;
case 39:
echo_image("HalloweenFest 2003 - Flinstones....",$img,"Can't this go any faster?");
break;
case 40:
echo_image("HalloweenFest 2003 -Here she comes to wreck the day!!!",$img,"I didn't know Elephants were princesses....");
break;
case 41:
echo_image("HalloweenFest 2003 - Umm.....",$img,"Perhaps we're looking at the grass... what a great costume.");
break;
case 42:
echo_image("HalloweenFest 2003 - ICE CREAM!!!",$img,"With rainbow Jimmies/Sprinkles");
break;
case 43:
echo_image("HalloweenFest 2003 - It's BAND TIME!!!",$img,"Ahh the sweet sounds of clowns.");
break;
case 44:
echo_image("HalloweenFest 2003 - I'm Macaroni",$img,"But I don't like to eat it");
break;
case 45:
echo_image("HalloweenFest 2003 - A Flowering Personality",$img,"Wassup?");
break;
case 46:
echo_image("HalloweenFest 2003 - umm.... ok?",$img,"Costumes of deserving noteriety...");
break;
case 47:
echo_image("HalloweenFest 2003 - AAAHHHHH!!!!",$img,"It's FUZZY & Up Close!!!!");
break;
case 48:
echo_image("HalloweenFest 2003 - I WIN!!",$img,"She got a trophy for something....");
break;
case 49:
echo_image("HalloweenFest 2003 - #4 in the line....",$img,"#1 in the Standings");
break;
case 50:
echo_image("HalloweenFest 2003 - Another trophy shot",$img,"Where did she go?");
break;
case 51:
echo_image("HalloweenFest 2003 - There she is....",$img,"I made her pop out of her box...");
break;
case 52:
echo_image("HalloweenFest 2003 - She Popped out....",$img,"Only because I went up her box....");
break;
default:
echo_thumbnail();
break;
}
?>My Image Loader
What should happen, is when the thumbnail is clicked, a new window pops-up and the title is defined in the echo_image() tag. Also the comment is defined there too. Problem is, is that neither show up. If you view the source code, the variables aren't passed so the HTML looks like this:
Code: Select all
<HTML><HEAD><TITLE></TITLE><META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD><BODY vLink=#009999 aLink=#0066CC link=#006666 bgColor=#006699><P align=center><IMG src="./images/2003halloweenFest01.jpg" border=0></P><P align=center><br><FONT color=#FFFFFF></FONT></P><P align=center> &nbsp;&nbsp;&nbsp;<A href="./imageLoader.php"><FONT face=Webdings color=#FFFFFF>l</FONT></FONT></A>&nbsp;&nbsp;&nbsp; </P></BODY></HTML><br />
<b>Fatal error</b>: Call to undefined function: stop() in <b>/afs/umbc.edu/users/b/r/brett2/pub/www/phpimageLoader/imageLoader.php</b> on line <b>8</b><br />Another problem (smaller yet easier) is the stop() function that I define. I call it so that the script stops there. Otherwise it creates two thumbnail pages, and a thumbnail page after the large image. So my question is:
What function can I call that will stop the script where I want it that won't cause it to error like it is now?
Thanks for the help you guys can offer.
~Brett Patterson