Jump to content

Need to Echo a Hash Symbol


cwbash

Recommended Posts

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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? 8)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.