0

I'm having a weird problem ,not sure what the title should be and I searched before posting this ,the collation of my database is set to utf8mb4_general_ci
and so is the column, yet when I type into the text field of that column the php code saves it just fine,how ever when this special text is copied from somewhere the column stays empty ! I already have this set in my code

 $this->connection = new mysqli(HOST, USER, PASS, DB);
 $this->connection->set_charset('utf8mb4');
user1702856
  • 31
  • 1
  • 2
  • 5

1 Answers1

0

You should use the following function before inserting it into database ,in which input_data is the data which you want to store in database . And the problem is database dont allow special character , and mostly these character are use for SQL injection , so this function do the cleaning stuff by escaping ,so the data is safe to save.

$mysqli->real_escape_string($input_data);

follow this link for documentation mysqli::real_escape_string

Afzaal
  • 42
  • 4
  • I have this class `class MySQL { public $connection; public function __construct($autoConnect = false) { if ($autoConnect === true) { $this->connect();} } public function connect() { $this->connection = new mysqli(HOST, USER, PASS, DB); $this->connection->set_charset('utf8mb4'); exit(); }} ` **now this is how I call it ,I'm sure I'm doing something wrong here** `$mysql = new MySQL(true); $description = mysqli_real_escape_string( $mysql, $description);` – user1702856 Dec 14 '16 at 15:53
  • $mysqli = new mysqli(true); – Afzaal Dec 14 '16 at 16:06
  • let me know if still problem exist @user1702856 – Afzaal Dec 14 '16 at 16:10
  • the same issue still exists ,nothing is saved in database – user1702856 Dec 14 '16 at 16:39
  • I have this class – user1702856 Dec 18 '16 at 10:41