script to remove extra white spaces from each and every fields of whole database table
20 July 2010
One Comment
Posts and pages
here is simple script to remove extra white spaces from each field of database table and get log record of how many fields age getting affected ! !
<?php
mysql_connect("localhost","root","");
mysql_select_db("temp");
if(isset($_GET['table']))
{
define("TABLE_NAME",$_GET['table']);
$sql = "select * from ".TABLE_NAME." ";
$rs = mysql_query($sql);
while($row = mysql_fetch_array($rs))
{
$flag = 0;
$i = 0;
foreach($row as $key => $value) {
if($flag == 0) {
$flag = 1;
} else {
$flag = 0;
$trimed = trim($value);
$temp = "update ".TABLE_NAME." set ".$key." = '".$trimed."' where id = '".$row[0]."' ";
mysql_query($temp);
if(mysql_affected_rows() == "1")
{
$i++;
echo "field trimed at id = ".$row[0]." and field = ".$key."";
}
} } }
if($i == "0") {
echo "no rows affected";
}
echo "DATABASE table trimed successfully";
}
else {
echo "no table defined";
}
?>









Buy:Prednisolone.Nexium.Synthroid.Lumigan.Human Growth Hormone.Zovirax.Actos.Mega Hoodia.Accutane.Retin-A.Prevacid.Arimidex.Petcam (Metacam) Oral Suspension.Valtrex.100% Pure Okinawan Coral Calcium.Zyban….
Leave your response!