Solved

Display Special characters  on web page (-- PHP)

Posted on 2012-03-19
8
313 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 110

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 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 25 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 125 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

730 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