0

When I save data from the form the data is stripped and strange characters are appended with data. I can't figure it out from the code. It was working fine and suddenly happened this thing. code is written in PHP

when I enter makhdoomfahim@yahoo.com

in the database table it saves as in the following image. enter image description here

Kutta
  • 95
  • 1
  • 4

3 Answers3

0

You should use in php trim (http://php.net/manual/en/function.trim.php) before passing the variable to mysql. Also you have to make sure that your mysql table is utf8_general_ci.

Example:

<?php
$con = mysql_connect("localhost","user","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$mail = trim($_POST['email']);

mysql_query("INSERT INTO Persons (email) VALUES (".$mail.")");

mysql_close($con);
?>

Also keep in mind the mysql_real_escape_string for securing the variables you insert in your database.

Mike
  • 3,017
  • 1
  • 34
  • 47
0

This looks like a Unicode replacement character eg see Removing unwanted character from column for further info

Community
  • 1
  • 1
kaj
  • 5,133
  • 2
  • 21
  • 18
0

I guess you did not use utf8_encode($input).Try this and see if your error is rectified.

dee
  • 194
  • 7