ironside82 Posted February 2, 2008 Share Posted February 2, 2008 I am trying to include html and php in a variable. here is an example of code: $msg = '<p><? echo $friend_firstname; ?> <? echo $friend_lastname; ?> (<? echo $friend_username; ?>) wants to add you as a friend. <a href="viewprofile.php?profile_id=<? echo $friend_id; ?>">View their profile</a></p><p><a href="req_friend.php?friendid=<? echo $user_id ?>">Add them as a friend</a></p>'; this information that the variable provides is then inserted into a database. when recalled from the database it should output: Joe Bloggs (joeb33) wants to add you as a friend View their profile //-> links to viewprofile.php?profile_id=8 Add as a friend //-> links to req_friend.php?friend_id=6 how ever it appers that the PHP elements that are encapsulated in the ' ' are not making their way thorough when their are later output again from the database. Is this an issue with the way the information in that variable to inserted in the database or when it is later echoed to a users inbox? It a little complicated to explain. Thanks again James Quote Link to comment https://forums.phpfreaks.com/topic/89078-variables-question/ Share on other sites More sharing options...
CerealBH Posted February 2, 2008 Share Posted February 2, 2008 $msg = "<p>$friend_fristname $friend_lastname $friend_username wants to add you as a friend."; $msg .= "<a href=\"viewprofile.php?profile_id=$friend_id\">View their profile</p><p>"; $msg .= "<a href=\"req_friend.php?friendid=$user_id\">Add them as a friend</p>"; think thats what ur lookin 4 Quote Link to comment https://forums.phpfreaks.com/topic/89078-variables-question/#findComment-456205 Share on other sites More sharing options...
CerealBH Posted February 2, 2008 Share Posted February 2, 2008 Explanation: $msg = '<p><? echo $friend_firstname; ?> <? echo $friend_lastname; ?> (<? echo $friend_username; ?>) wants to add you as a friend. <a href="viewprofile.php?profile_id=<? echo $friend_id; ?>">View their profile[/url]</p><p><a href="req_friend.php?friendid=<? echo $user_id ?>">Add them as a friend[/url]</p>'; ' ' = literal, so your page was outputting <? echo $friend_fristname ?> and not processing it, and u dont need the <? ?> in thereunless u were using php to generate a php page source, which im almost positive ur not cuz thats kinda pointless unless ur in high end development :/ useing " lets php replace all those variables, and on your html code, dont' forget to escape " : href="blah blah" should be href=\"blah blah\" in php code Quote Link to comment https://forums.phpfreaks.com/topic/89078-variables-question/#findComment-456207 Share on other sites More sharing options...
ironside82 Posted February 2, 2008 Author Share Posted February 2, 2008 Genius, That worked a charm Thanks a lot James Quote Link to comment https://forums.phpfreaks.com/topic/89078-variables-question/#findComment-456209 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.