Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

document.referrer is providing accented letters

Tags:

php

mysql

I'm using document.referrer for grabbing previous URL of current page and sending it to a curl file,that curl file again send this variable to a PHP file for saving it into data base. The problem is that on saving into database I'm getting URL value as accented letters like

†Ûiÿû®û(~×(›û®û(~×â•ïðŠwhÂÏڞئj­î

I've used base64 coding scheme in my php file.The collation of MySQL column is latin1_swedish_ci.

Thanks.

like image 780
Vandana Pareek Avatar asked Dec 25 '12 12:12

Vandana Pareek


People also ask

Why is document referrer empty?

Description. The referrer property contains the URL of the document that was used to reach the current document. If the URL was typed directly into the browser's location field, this property will be empty.

What is window document referrer?

document. referrer gives you the URI of the page that linked to the current page. This is a value that's available for all pages, not just frames. window. parent gives you the parent frame, and its location is its URI.

How is document referrer set?

The Referer header is set by your browser and sent to the server when you request a page. The value of this header is the URL of the previous page that linked to the newly requested page. It is where you came from, essentially.

Can we change document referrer?

You can't, document. referrer is a read-only property, which value changes only when picking a link.


1 Answers

As the commenter suggests, I think this is simply a problem where the encoding of the URL isn't the same as the encoding of your database. Using utf-8 on your database tables would solve most (if not all) of your problems. Here is a two part article (part 1 and part 2) that discusses how to use utf-8 in PHP and MySQL.

like image 58
Jonah Bishop Avatar answered Sep 16 '22 11:09

Jonah Bishop