PHP ile MySQL dosya yolunu güncelleniyor çalışmıyor

2 Cevap php

I am storing network share paths in my table in MySQL. but some entries got corrupted, i.e they dont have any backslashes in between. Path is like a big word. I wrote a small script in PHP to update these paths to try and add slashes. It does not give me any error when I run it but the results are not getting updated in the table.

Currently the path in my tables is like this: \fil01logsTestDat1oop_s2010Log and I want to make it \\fil01\logs\Test\Dat1\oop_s\2010\Log

If I echo the last $ch7 the results is what I want but it is not going into the table.

$result = mysql_query("select dbresultsid,ResultDirectory from results where dbresultsid > 48717") or die(mysql_error());  
$i= 0;
// store the record of the "example" table into $row
while($row = mysql_fetch_array( $result )) {

$ch = $row['ResultDirectory'];
$id  = $row['dbresultsid'];


if(strstr($ch, $fsd))
{
//echo 'Yes'.$i.'<br>';
//$i++;
$ch1 = str_replace("fil01","\\fil01\\",$ch);
$ch2 = str_replace("logs","logs\\",$ch1);
$ch3 = str_replace("Test","Test\\",$ch2);
$ch4 = str_replace("Dat1","Dat1\\",$ch3);
$ch5 = str_replace("oop_s","oop_s\\",$ch4);
$ch6 = str_replace("2010","2010\\",$ch5);
$ch7 = str_replace("Log","\\Log",$ch6);
//echo trim($ch7).'<br>';
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("opp") or die(mysql_error());
echo "Updating $id with $ch7 <br>";
$update_again = mysql_query("update results set ResultDirectory = \"$ch7\" where dbresultsid = \"$id\" ") or die(mysql_error());  
echo "Updated record $i <br>";
$i++;
}

}

?>

Herhangi bir fikir?

Teşekkürler.