Page 1 of 1
problem with with code
Posted: Wed Aug 11, 2010 5:15 am
by kevrelland
Hi
I'm having trouble with the conditional if statements in this link
Code: Select all
<a href="upload.php?image_postion='.$_GET["image_position"].'&type=list&page="1"&id='.$_GET["id"].'&url='.$_GET["url"] if ($_GET["image_id_1"]!="") { echo '&image_id_1='$_GET["image_id_1"];} if ($_GET["image_id_2"]!="") { echo '&image_id_2='$_GET["image_id_2"];} if ($_GET["image_id_3"]!="") { echo '&image_id_3='$_GET["image_id_3"];}'"><< First</a> | ';
I get "Parse error: syntax error, unexpected T_IF" and i'm stuck at work without my php book and just can't figure it out
What have i done wrong and how do i fix it
Cheers
Kev
Re: problem with with code
Posted: Wed Aug 11, 2010 5:26 am
by internet-solution
My head is spinning after looking at the code!

I fail to see any propoer syntax or logic.
You need to separate your conditional (if) statements from your echo function. Carry out the conditional checks first,define variables and then in echo you join the variable with strings.
Re: problem with with code
Posted: Wed Aug 11, 2010 5:35 am
by kevrelland
basically i want the url to have image_id_1,2 or 3 display if it has been passed from the previous page
It might not be right, i had to do a quick fix for the client, bloody last min changes
I have it working here:-
Code: Select all
<p><a href="<?php echo $_GET["url"]; ?>.php?image_id<?php echo $_GET['image_position']; ?>=<?php echo stripslashes($row['imagename']); ?><?php if ( $_GET["image_id_1"]!="") { ?>&image_id_1=<?php echo $_GET["image_id_1"]; ?><?php } ?><?php if ( $_GET["image_id_2"]!="") { ?>&image_id_2=<?php echo $_GET["image_id_2"]; ?><?php } ?><?php if ( $_GET["image_id_3"]!="") { ?>&image_id_3=<?php echo $_GET["image_id_3"]; ?><?php } ?>&id=<?php echo $_GET["id"]; ?>" class="btn2 corners"><span class="white_text">Choose this image</span></a></p>
and i wanted to get it working as as above
Kev
Re: problem with with code
Posted: Wed Aug 11, 2010 6:06 am
by internet-solution
Compare the two codes you have posted above. In first one (not working) the <?php ?> tags are missing.
Re: problem with with code
Posted: Wed Aug 11, 2010 6:30 am
by kevrelland
I know the tags are missing the second one is within the html and the first one is built in the php then echo'd out
kev
Re: problem with with code
Posted: Thu Aug 12, 2010 1:47 am
by kevrelland
Ok i think i'm gonna go down a different route with this now.
and i just want to bounce the my method around out there to see if i'm going down the right road.
The problem is that i use 1 image list page for three different pages, ie news_update, weblink_update and on each page are three different images.
As you can see previously i tried to keep information by passing it in the url.
So i thought about sessions and storing the info in a session as i go.
So my question is would that be a good way of doing it
Cheers
Kevin