Jump to content


Photo

Syntax help


  • Please log in to reply
8 replies to this topic

#1 martyng

martyng
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 05 June 2006 - 11:26 PM

I read a recordset into an array and one part is shown below. I need to replace the numeral 1 with the variable picture, which i tried to do by just replacing 1 with $picture but can't get it work, any ideas

"link"=>"<A HREF=\"profile.php?id=$row[id]\"><IMG SRC=\"pictures/$row[gallery1]\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>",

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 05 June 2006 - 11:30 PM

I don't see any 1s but try this

"link"=>"<A HREF=\"profile.php?id=".$row['id']."\"><IMG SRC=\"pictures/".$row['gallery1']."\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>",

NoGray.com


#3 martyng

martyng
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 05 June 2006 - 11:43 PM

Sorry, unclear, i Need to replace the 1 in gallery1 with the variable $picture ie. like $row[gallery$picture] but this doesn't work

#4 KrisNz

KrisNz
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts
  • LocationAuckland, New Zealand

Posted 05 June 2006 - 11:54 PM

try
"<A HREF=\"profile.php?id=$row[id]\"><IMG SRC=\"pictures/".$row['gallery'.$picture]."\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>";


#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 06 June 2006 - 12:05 AM


$row['gallery1']=$picture;

"link"=>"<A HREF=\"profile.php?id=".$row['id']."\"><IMG SRC=\"pictures/".$row['gallery1']."\" 

WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>",


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 martyng

martyng
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 06 June 2006 - 08:39 AM

Still no luck, gallery1 refers to a row in a table. I also have a row called gallery2 and to create a random galery I have the random variable $picture with a value of either 1 or 2. The code works fine with a fixed [gallery1] or [gallery2] but not by trying to replace the 1 with $picture.


KrisNz's post looks closest to what i'm trying to do but still doesn't work giving the following
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in

Any ideas guys

#7 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 06 June 2006 - 08:57 AM

"<a href=\"profile.php?id={$row['id']}\"><img src=\"pictures/{$row['gallery$picture']}\" width=\"132\" height=\"175\" border=\"0\"></a>";


#8 martyng

martyng
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 06 June 2006 - 03:57 PM

Nearly there, this doesn't produce an error but doesn't add the information contained in gallery$picture looking at the source code the image is just pictures/ with nothing tagged on

Any ideas



[!--quoteo(post=380530:date=Jun 6 2006, 03:57 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 6 2006, 03:57 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
"<a href=\"profile.php?id={$row['id']}\"><img src=\"pictures/{$row['gallery$picture']}\" width=\"132\" height=\"175\" border=\"0\"></a>";
[/quote]


#9 martyng

martyng
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 06 June 2006 - 11:04 PM

Still couldn't figure it out, but got around it by checking value of $picture and using two different statements with a fixed gallery1 or gallery2

I'd still love to know how to do it properly tho as my way is messy and only good as I only have two variable choices 1 or 2




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users