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 &? Quote Link to comment 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). Quote Link to comment 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? Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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> Quote Link to comment 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? Quote Link to comment 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.