martyng Posted June 5, 2006 Share Posted June 5, 2006 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>", Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/ Share on other sites More sharing options...
nogray Posted June 5, 2006 Share Posted June 5, 2006 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>", Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42223 Share on other sites More sharing options...
martyng Posted June 5, 2006 Author Share Posted June 5, 2006 Sorry, unclear, i Need to replace the 1 in gallery1 with the variable $picture ie. like $row[gallery$picture] but this doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42230 Share on other sites More sharing options...
KrisNz Posted June 5, 2006 Share Posted June 5, 2006 try [code]"<A HREF=\"profile.php?id=$row[id]\"><IMG SRC=\"pictures/".$row['gallery'.$picture]."\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42235 Share on other sites More sharing options...
redarrow Posted June 6, 2006 Share Posted June 6, 2006 [code]$row['gallery1']=$picture;"link"=>"<A HREF=\"profile.php?id=".$row['id']."\"><IMG SRC=\"pictures/".$row['gallery1']."\" WIDTH=\"132\" HEIGHT=\"175\" BORDER=\"0\"></A>",[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42238 Share on other sites More sharing options...
martyng Posted June 6, 2006 Author Share Posted June 6, 2006 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 inAny ideas guys Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42334 Share on other sites More sharing options...
trq Posted June 6, 2006 Share Posted June 6, 2006 [code]"<a href=\"profile.php?id={$row['id']}\"><img src=\"pictures/{$row['gallery$picture']}\" width=\"132\" height=\"175\" border=\"0\"></a>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42341 Share on other sites More sharing options...
martyng Posted June 6, 2006 Author Share Posted June 6, 2006 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 onAny ideas[!--quoteo(post=380530:date=Jun 6 2006, 03:57 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 6 2006, 03:57 AM) [snapback]380530[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]"<a href=\"profile.php?id={$row['id']}\"><img src=\"pictures/{$row['gallery$picture']}\" width=\"132\" height=\"175\" border=\"0\"></a>";[/code][/quote] Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42448 Share on other sites More sharing options...
martyng Posted June 6, 2006 Author Share Posted June 6, 2006 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 gallery2I'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 Quote Link to comment https://forums.phpfreaks.com/topic/11281-syntax-help/#findComment-42630 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.