cwbash Posted August 22, 2010 Share Posted August 22, 2010 Trying to echo a string that contains a hash symbol. Instead of getting a hash symbol, I get %29. The code I am using is pretty basic -->$idx="#" . $idxA;<--, but as stated, when I echo $idx, it comes out as %29. (All of this is part of a form, get, attempting to pass a bookmark to the receiving program. Thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/ Share on other sites More sharing options...
kenrbnsn Posted August 22, 2010 Share Posted August 22, 2010 Please post more of your code. Ken Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102508 Share on other sites More sharing options...
cwbash Posted August 23, 2010 Author Share Posted August 23, 2010 The more complete code is $idxA=mysql_result($result,$i,"idxA"); $idxN=mysql_result($result,$i,"idxN"); $idxS=mysql_result($result,$i,"idxS"); $idx="#" . $idxA . $idxN . $idxS; $rgn = mysql_result($result,$i,"rgnId"); $pageId=mysql_result($result,$i,"pageId"); $pageIdx=mysql_result($result,$i,"pageIdx"); $ltLabel=mysql_result($result,$i,"ltLabel"); ?> <form action="../showSql.php" method="get"> <table> <tr> <td style="width:250px"> <input name="file" type="text" value="<? echo $rgn . '/' . $pageId . $idx; ?>" style="width: 250px" /> </td> <td style="width:250px"> <input type="text" style="width: 245px" value="<? echo $ltLabel; ?>" /> </td> <td> <input value="Open Page" type="submit" /></td> </tr> </table> </form> --------------------- The operative form problem is the 'form, type=get' where I hope to get the following echoed -->../showSql.php?file=RG/pageID#xx123S. What comes out is not a hash symbol by the ;023 (which I assume is the internal code for a hash symbol, but none of my browsers treat it that way.) Overtype the ;023 with a hash symbol, and they work correctly. Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102523 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 That's because the form encodes the hash, why not just uses an anchor tag ? eg echo '<a href="../showSql.php?file='.$rgn.'/' . $pageId . $idx.'">Open Page</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102527 Share on other sites More sharing options...
cwbash Posted August 23, 2010 Author Share Posted August 23, 2010 Well, I guess "madtechie", that the reason I didn't choose another solution is because I wanted to get the FORM to work. I agree, that either the form or the PHP is encoding the hash symbol, the question is "how do I get it to not do so?" I've tried inserting the '\' symbol in front, that doesn't work either. Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102542 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 Okay first of all their no need to be condescending, The reason you didn't pick another may of been you don't know another, (considering this actual problem) I was giving you an alternative as your form was pretty basic!, if your form was more complex then i would of given you the you the answer your looking for and in fact I have partly given you the answer.. good day! Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102548 Share on other sites More sharing options...
cwbash Posted August 23, 2010 Author Share Posted August 23, 2010 I did not intend to be condescending, but intended to clarify the reason I asked the question. Yes, your solution fixed the problem (and after 35 years of IT, and 10 years of retirement, I do understand the mantra "when it doesn't work, do it differently and it might.") I would still like to understand how I can make FORM not alter my hash symbol so it comes out as I intended. Thanks for the technical solution, but "does anybody else have a way to make PHP keep it's hands off of my hash symbol? Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102564 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 if your using one form for each "open page" button then you could put it in the action ie this is the correct way to pass the # in a form <form action="<?php echo '../showSql.php?file='.$rgn.'/' . $pageId . $idx; ?>" I assume you wish to use the # to jump down to a anchor on the next page, a possible third option would be to create a middle page that you can use get or post to and that would process the form and redirect to the next page with an anchor, it really depends on what your goal is. Hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102567 Share on other sites More sharing options...
MadTechie Posted August 23, 2010 Share Posted August 23, 2010 Oh i forgot to say.. another option would be to update the action via a javascript Quote Link to comment https://forums.phpfreaks.com/topic/211454-need-to-echo-a-hash-symbol/#findComment-1102570 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.