?
Solved

Display Special characters  on web page (-- PHP)

Posted on 2012-03-19
8
Medium Priority
?
316 Views
Last Modified: 2012-03-20
Hello,
  I have  some data in a database that I trying display on Webpage but I am having some  issues with postback.

Table data

Index|CID|PH|Devicename
1|/+@<`|561| P1
2|123|561923|P2

To display the data on the page I used the urlencode($row["$this->CID"]).

The page is display ok with a hyperlink.
     $value = "<a href=$myroot/display/CID/$cid/top/$top/StartDate/$sd/sys/" . $this->sys . ">$value</a>";
 echo "<td>$value</td>\n";

When I click on the CID link I get "page cannot be found" for the entry with the special characters

This is the URL after the encoding
https://myserver/public/index.php/index/display/CID/%2F%3C%2F%3E%2B%40%3C%60/top/1/StartDate/2012-02-26/sys/sys1

It does not get to the postback page..

Thanks for the help
0
Comment
Question by:SiemensSEN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37738327
urlencode() is typically used to encode the values passed to URLs but not the string inside the address portion of the URL.  Have you got this online somewhere that we can see it in action?
0
 

Author Comment

by:SiemensSEN
ID: 37738423
Sorry . No access from the outside

I am attaching a screen print

Screen print - This is part of teh screen displayed to the user

The URL-<a ref> for the first entry is

https://myserver/public/index.php/index/display/CID/b8899d01cb5062e6/top/OSS/StartDate/2012-03-04/sys/BocaFT5

URL for the second entry (with the special characters is)

https://myserver/public/index.php/index/display/CID/%2F%26lt%3B%2F%26gt%3B%2B%40%26lt%3B%60/top/OSS/StartDate/2012-03-04/sys/BocaFT5

Clicking on first entry OK
Clicking on second entry -- page cannot be found
Link.jpg
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 37738483
Do you actually have a URL with that name, containing the special characters?  I think a better design might be to rely on a key (perhaps the Index column) to locate the data you want to display.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:SiemensSEN
ID: 37738767
Thanks.
No I do not  have a URL with the special character. I use the urlencode(cid) when I display the page. So, it translate the '/+@<`' to %2F%26lt%3B%2F%26gt%3B%2B%40%26lt%3B%60
0
 
LVL 4

Expert Comment

by:dmgroom
ID: 37743150
I see you are linking to https://myserver/public/index.php/index/display/CID/%2F%26lt%3B%2F%26gt%3B%2B%40%26lt%3B%60/top/OSS/StartDate/2012-03-04/sys/BocaFT5

So does the script https://myserver/public/index.php contain code which decodes the rest of the URL string and then performs some action?

If so, is the code which handles this working correctly, do you urldecode the data before doing whatever else you do to it?
0
 

Author Comment

by:SiemensSEN
ID: 37743945
Thanks,
  The problem is ... it never get to the postback page (controller) for me to decode the information.

When I click the first link  I can capture the argument. however, the second link(with the special characters) does not get to the postback page . It seem to die at the webserver level..
0
 
LVL 4

Accepted Solution

by:
dmgroom earned 500 total points
ID: 37744198
are you are to replace the "/" after php with a "?" so
https://myserver/public/index.php/index/display/CID/%2F%26lt%3B%2F%26gt%3B%2B%40%26lt%3B%60/top/OSS/StartDate/2012-03-04/sys/BocaFT5

becomes

https://myserver/public/index.php?index/display/CID/%2F%26lt%3B%2F%26gt%3B%2B%40%26lt%3B%60/top/OSS/StartDate/2012-03-04/sys/BocaFT5 

But if I'm totally honest I really dislike the whole URL you are trying to use.  I suppose its too simple to suggest that you dont allow these special characters in the CID field
0
 

Author Comment

by:SiemensSEN
ID: 37744245
replace the "/" with & works.  Do you know why the "/" would not work?

The CID field is used as a key to find other information.  It is a value generated by a device.

I agree with you and will used the index as the key look up.

Thanks for your help
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question