runnerjp Posted May 31, 2008 Share Posted May 31, 2008 <?php if($gettopic3['forumlock'] == 0){echo '<A href="index.php?page=reply&id=$id"><img src="http://www.runningprofiles.com/images/post_reply.gif" border="0" /><br> </A>'; } else {echo 'forum is locked';} ?> how would i get id=$id to work :S Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/ Share on other sites More sharing options...
kbh43dz_u Posted May 31, 2008 Share Posted May 31, 2008 Don't use simple ' but " ... because everything within simple ' is not interpreted as PHP! Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554174 Share on other sites More sharing options...
Prismatic Posted May 31, 2008 Share Posted May 31, 2008 <?php if($gettopic3['forumlock'] == 0) { echo "<a href='index.php?page=reply&id={$id}'>[/url]"; } else { echo 'forum is locked'; } ?> Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554176 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 ok i did this <?php if($gettopic3['forumlock'] == 0) { echo "<a href='index.php?page=reply&id={$id}'><img src="http://www.runningprofiles.com/images/post_reply.gif" border="0" />[/url]"; } else { echo 'forum is locked'; } ?> and i got expecting '' of ; for echo "<a href='index.php?page=reply&id={$id}'><img src="http://www.runningprofiles.com/images/post_reply.gif" border="0" Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554183 Share on other sites More sharing options...
wildteen88 Posted May 31, 2008 Share Posted May 31, 2008 You need to escape any double quotes within a string which starts/ends in double quotes. <?php if($gettopic3['forumlock'] == 0) { echo "<a href=\"index.php?page=reply&id=$id\"><img src=\"http://www.runningprofiles.com/images/post_reply.gif\" border=\"0\" /></a>"; } else { echo 'forum is locked'; } ?> Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554188 Share on other sites More sharing options...
kbh43dz_u Posted May 31, 2008 Share Posted May 31, 2008 you have to escape the inner " because otherwise PHP thinks you want to end your string. change " to \" like this: <?php if($gettopic3['forumlock'] == 0) { echo "<a href='index.php?page=reply&id={$id}'><img src=\"http://www.runningprofiles.com/images/post_reply.gif\" border=\"0\" />[/url]"; } else { echo 'forum is locked'; } ?> Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554189 Share on other sites More sharing options...
runnerjp Posted May 31, 2008 Author Share Posted May 31, 2008 thanks guys... more added to my php smell knowledge to escape " within "" Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554200 Share on other sites More sharing options...
wildteen88 Posted May 31, 2008 Share Posted May 31, 2008 thanks guys... more added to my php smell knowledge to escape " within "" You mean \" right? Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554216 Share on other sites More sharing options...
kbh43dz_u Posted May 31, 2008 Share Posted May 31, 2008 no, he ment withIN "" (not "with") Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554218 Share on other sites More sharing options...
wildteen88 Posted May 31, 2008 Share Posted May 31, 2008 Doh! Mis read the post. Link to comment https://forums.phpfreaks.com/topic/108121-solved-using-php-within-a-link-within-php/#findComment-554219 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.