0

This is my code,

require_once 'libraries/htmlpurifier/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);

$lDesc = $_POST['long-desc'];
$lDesc = $purifier->purify($lDesc);
$lDesc = mysql_real_escape_string($lDesc);

if the long description have a link, the href tag converted as the following: href="%5C"

previously I solved this error by processing HTMLPurifier before mysql_real_escape_string and it is also still working on my localhost (inserting the real link in the href tag) but on the live server it gives that error!

any ideas?

Bassem Shahin
  • 656
  • 7
  • 13
  • 1
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[this happens](https://media.giphy.com/media/kg9t6wEQKV7u8/giphy.gif)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly May 18 '17 at 09:19
  • however your comment have no relation with my question, as you can totally skip that line and just echo the result, but in fact, it gives me the solution :D the problem was that the server was using PHP v 5.2 I raise it to 5.4 and it is working properly now! – Bassem Shahin May 18 '17 at 09:54

1 Answers1

0

The server PHP version was 5.2 I modify it to "PHP version: 5.4" This solve that error!

Bassem Shahin
  • 656
  • 7
  • 13