0

I want to do a "select all" from a table, using an URL. However the URLs stored in my database have funny characters; an URL in my database looks something like this:

http%3A%2F%2Fwww.indeed.co.uk%2Fviewjob%3Fjk%3D62643ba09fe2e936%26qd%3DUl8d87NuQZQD4fDpyxUj6Q3nWG6Z80ksB5Olwd1QWW3wG-YZeyT0yxf8fUYia7g-jLgw8Q9quijZp6li7FQTOh_bZiy_HhLQe1iSKacCzeM%26indpubnum%3D2878078796677777%26atk%3D185867g360mq25sg

How would I select this by using a normal URL string such as "http://www.indeed.co.uk/blablabla", without all the funny %3A%2F characters.

Or is there a way to insert the urls into the database without these characters getting added in. If so how?

gray
  • 798
  • 18
  • 31

2 Answers2

0

Those are URI encoded characters. It's not clear how those ended up in your database, though it's possible they weren't properly decoded before being saved.

It's sort of possible to decode these in MySQL alone but it's usually better to use a scripting language of some sort to do the conversion for you.

Community
  • 1
  • 1
tadman
  • 208,517
  • 23
  • 234
  • 262
0

If you use PHP, you can use the function urlencode :

$query = "SELECT * FROM table WHERE url = '" . urlencode($urlToSearch) . "'";

Documentation PHP.net

Elorfin
  • 2,487
  • 1
  • 27
  • 50