1

I'm sending an string via an url.

The string I wrote is :

"tasse(s)", size : 8

When i transmit it from the url, it encodes the string, so it's like that :

 string(16) "tasse(s)"

and If I get more info, its :

string(16) "tasse(s)"

So, after receiving my parameter via url, it's possible to get back :

"tasse(s)", size : 8

Because "tasse(s)", size : 8 exist in my Mysql BDD, but when I compare it with "tasse(s)", size : 16, it consider they are not the same ..

Someone have an solution for that ?

Code :

{assign var="myUri" value=site_url("admin/deleteRowInRecipe/"|cat:$recette[$i]->id|cat:"/"|cat:$ingredient|cat:"/"|cat:$quantite|cat:"/"|cat:$unite)}   

<a href="{$myUri}"><input type="button" value="Supprimer"></a>

In my console firefox/chrome :

<a href="http://localhost/CodeIgniter_RECETTE-copie/admin/deleteRowInRecipe/52/curcuma/1/3/tasse(s)">
<input type="button" value="Supprimer"></a>
                        <br/>
Choubidou
  • 351
  • 2
  • 4
  • 17

1 Answers1

1

Those are htmlentities, Code Igniter is somewhere escaping the parameter (or you're doing it inadvertently). To get the correct value you can use html_entity_decode.

$ php -r 'var_dump(html_entity_decode("tasse&#40;s&#41;"));'
string(8) "tasse(s)"
Martin
  • 6,632
  • 4
  • 25
  • 28
  • I said I can get the correct value, it's not the problem, the problem is the size 16 and size 8, so when I try to do a comparaison in BDD, it doesn't works .. – Choubidou Dec 29 '13 at 23:45
  • If you convert the string into ascii it will return a string of 8 characters. Try it :) – Martin Dec 29 '13 at 23:45
  • This is likely correct, but it's arguably better to try and fix the root cause if at all possible. – Pekka Dec 29 '13 at 23:48
  • I tried it with this function `public function string_to_ascii($string) { $ascii = NULL; for ($i = 0; $i < strlen($string); $i++) { $ascii += ord($string[$i]); } return($ascii); }` The same thing .. – Choubidou Dec 29 '13 at 23:49
  • @Choubidou that is not the same thing, try `html_entity_decode($string)`. – Martin Dec 29 '13 at 23:56
  • @Pekka웃 I agree, but without code there's not much else we can do at this point. – Martin Dec 29 '13 at 23:56
  • Already tested html_entity_decode($igd,ENT_QUOTES,"UTF-8") and $igd = html_entity_decode($igd); I think i'm gonna to die ! – Choubidou Dec 29 '13 at 23:58
  • $ php -r 'var_dump(html_entity_decode("tasse(s)"));' string(8) "tasse(s)" – Martin Dec 30 '13 at 00:00
  • Yeah it was this .. I was doing the test in a different variable .. I'm sorry and thanks you so much Marin and Pekka – Choubidou Dec 30 '13 at 00:05