Guest Posted January 11, 2007 Share Posted January 11, 2007 I have a variable that will contain a address that has a & in it when i echo it it comes out as [code]&[/code] hw do i make it print as &? Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/ Share on other sites More sharing options...
obsidian Posted January 11, 2007 Share Posted January 11, 2007 How are you handling the variable? If it only contains '&' and it's coming out as '&', you have to be using some sort of html encoding function on it (htmlentities() or such). Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158297 Share on other sites More sharing options...
Guest Posted January 11, 2007 Share Posted January 11, 2007 this is how im using it.[code]$address = "$website/view.php?id=$hid&image=1"; [/code]when it trys to get the image is uses & where the & sign isim just using echo and its doing this why is that? Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158553 Share on other sites More sharing options...
Asheeown Posted January 11, 2007 Share Posted January 11, 2007 [code]$address = "".$website."/view.php?id=".$hid."&image=1"; [/code] Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158564 Share on other sites More sharing options...
Guest Posted January 11, 2007 Share Posted January 11, 2007 I try that and it still is coming the exact same Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158603 Share on other sites More sharing options...
kenrbnsn Posted January 11, 2007 Share Posted January 11, 2007 Please post the rest of your script.Ken Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158617 Share on other sites More sharing options...
Guest Posted January 11, 2007 Share Posted January 11, 2007 [code]$simage = "" . $website . "/inc/view.php?type=house&id=$hid&image=1&hei=100&wid=100";[/code][code]echo "<td rowspan='5' align='left' width='100'><a href='Details.php?hid=$hid' border='0'><img src='$simage' border='0'></a></td>\n";[/code] Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158622 Share on other sites More sharing options...
kenrbnsn Posted January 11, 2007 Share Posted January 11, 2007 Ia that your whole script?When are you noticing that the "&" changes to "&"?Ken Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158639 Share on other sites More sharing options...
Guest Posted January 11, 2007 Share Posted January 11, 2007 That is the only time $simage I notice a change when I view the webpage. Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158654 Share on other sites More sharing options...
kenrbnsn Posted January 11, 2007 Share Posted January 11, 2007 The "&" character and "&" should both be translated to the "&" by the browser.What do you see if you do a "show source" with the browser?Do you have a publicly accessible web site that shows the problem.Ken Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158663 Share on other sites More sharing options...
Guest Posted January 11, 2007 Share Posted January 11, 2007 Yes i see it in the source. No i dont have a website to access it right now. Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158669 Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 [quote author=jeff8j link=topic=121948.msg502625#msg502625 date=1168554127][code]$simage = "" . $website . "/inc/view.php?type=house&id=$hid&image=1&hei=100&wid=100";[/code][/quote]That first "" . is superfluous. This is a pretty wacky problem. That is your exact code? You're not running any functions on the string, or getting it from a db, etc? Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158671 Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 [quote author=jeff8j link=topic=121948.msg502672#msg502672 date=1168556424]Yes i see it in the source. No i dont have a website to access it right now.[/quote]He asked what do you see in the source :-PI know there are some restrictions on what html can be used inside of a table cell. What happens if you print it outside of a cell? Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158672 Share on other sites More sharing options...
Guest Posted January 11, 2007 Share Posted January 11, 2007 I see this in the code[code]<img src="inc/view.php?type=house&id=7&image=1">[/code] Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158676 Share on other sites More sharing options...
kenrbnsn Posted January 11, 2007 Share Posted January 11, 2007 I tested this very short script to see if I could duplicate the problem:[code]<?phpecho '<a href="http://www.example.com/index.php?x=1&y=2&z=3&a=ten"><img src="http://www.example.com/img.php?x=1&y=2"</a>';?>[/code]I couldn't.Could you see you this script causes the problem on your server?Ken Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158677 Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 You see that even if you put it outside the cell?Are you using some sort of CMS or is this pure code? Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158678 Share on other sites More sharing options...
Guest Posted January 11, 2007 Share Posted January 11, 2007 pure php what do you mean outside the cell. Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158680 Share on other sites More sharing options...
Jessica Posted January 11, 2007 Share Posted January 11, 2007 instead of in a table, just print it somewhere else. No <td> stuff. Outside of your <table> Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158681 Share on other sites More sharing options...
Draicone Posted January 11, 2007 Share Posted January 11, 2007 It should actually work fine. In fact, for URLs and SRCs, you're meant to use an & to encode the & (because the & denotes a HTMl character entity, which is not present, so you have to use the entity for the & itself). What PHP version are you using? Link to comment https://forums.phpfreaks.com/topic/33751-inside-variable/#findComment-158708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.