We help IT Professionals succeed at work.

GET URL with special characters

Refael
Refael asked
on
216 Views
Last Modified: 2012-03-27
Hello Experts,

I am using FPDF.

The first line in the code is:

$companyTitle = stripslashes($_GET['companyTitle']);

Open in new window


The problem with the above code is when $companyTitle contains special characters such as an ampersend "&" sign.

I am trying using "urlencode" like so:

$companyTitle = urlencode($_GET['companyTitle']);

Open in new window


But for some reason it does not help.

can anyone help?
Comment
Watch Question

Chris SandriniSenior System Engineer
Top Expert 2012

Commented:
Have you tried to use htmlentities() ?

Author

Commented:
Hi,

like so?  
$companyTitle = htmlentities($_GET['companyTitle']);

Open in new window


Yes i did. does not work!
Chris SandriniSenior System Engineer
Top Expert 2012

Commented:
Can you explain what does not work? What is the output of $companyTitle. And what is the content of $_GET['companyTitle']

Author

Commented:
Hi un1x86, thanks

Lets say the company name is : T & TINT
The URL is something like this:
https://www.domain.com/admin/print_pdf.php?mid=570&companyTitle=T & TINT

the code is:

$companyTitle = htmlentities($_GET['companyTitle']);  // get the variable
$title = 'Company Name: '. $companyTitle;  // echo in FPDF

Open in new window


when it prints the PDF, the companyTitle is shown like so:

Company Name: T
Senior System Engineer
Top Expert 2012
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
un1x86 Thank you!

that was a good reminder where to look for the "problem".
i did exactly as you suggested and it works perfect!
Chris SandriniSenior System Engineer
Top Expert 2012

Commented:
Glad I could help.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.