php,sql - how to alter values from one column and inserting it into other
<p>I wanna get the values from a column <code>column1</code> and delete all the 
<em>(spaces , %20, %2520, _ (underscore), - (hyphen) and . (dot))</em> from it and save the values to the corresponding place in other <code>column2</code>.<br>
Is this the right way to do it? will this even work?</p>

<pre><code>$conn = new mysqli($servername, $username, $password,$dbname);

$sql= "SELECT column1 FROM table" ;

$result = $conn-&gt;query($sql);

if ($result-&gt;num_rows &gt; 0) {

while($row = $result-&gt;fetch_assoc()) {


    $x= $row["column1"] ;


$find=array(" ","%20","%2520",".","-","_");
$x= str_replace($find,'',$x);


               $sql2 ="INSERT INTO table
             ( column2 )
             VALUES
             ( '$x' )";

              if ($conn-&gt;query($sql2) === TRUE) {
               echo "Record Created &lt;br&gt;";

                }

              else {
               echo "Error creating Record: " . $conn-&gt;error;
               }

    }
} else {
    echo "0 results";
}
$conn-&gt;close();
</code></pre>