PHP MySql - 插入和选择数据时,撇号数量增加一倍

When And Data is inserted into MySql containing apostrophe ('), it doubles itself.

Thus, if I try inserting

I'm 

The value when checked via phpmyadmin becomes

I''m

Similarly on retrieving the data it becomes

I''''m

My Php Code is

$con=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME) ;
     // Check connection 
    //mysql_set_charset('utf8', $con);
    //mysqli_set_charset($con,'latin1_swedish_ci'); 
    //echo mysqli_get_charset($con);

    if (mysqli_connect_errno())
    { 
        echo "Error";
        exit;
    }
      mysqli_query( $con , "SET character_set_results=latin1_swedish_ci");
    //echo mysqli_character_set_name($con);
    $result = mysqli_query($con,$query);   
    mysqli_close($con);

I have tried changing charset on tables and also on while I retrieve the data by above code. But still it keeps doubling apostrophes number.

Update :

When I execute same program on different server, it functions properly. Does this means it's a malfunction of my server side.

Use mysqli_real_escape_string() function before inserting.

$stringToStore= mysqli_real_escape_string($con,$stringToStore);

And also retrieve value in PHP and echo that, to check is there any problem with php myadmin or not.