$page = intval($_GET['p']);
$pp = 350;
$start = $page*$pp;
$link = mysqli_connect($host,$user,$pass);
if($link) { if(mysqli_select_db($link,$datb)){
mysqli_query($link,"SET NAMES 'utf8'");
mysqli_query($link,"SET CHARACTER SET 'utf8'");
}
}
$q = "SELECT thread_id,CONVERT(tags USING utf8) AS tagx, LENGTH(tags) AS tl FROM xf_thread WHERE LENGTH(tags)>5 LIMIT $start,$pp";
$r = mysqli_query($link,$q);
while($row = mysqli_fetch_assoc($r))
{
$row_arr[] = $row;
}
foreach($row_arr AS $row){
$t = unserialize($row['tagx']);
$threadID = $row['thread_id'];
echo "<pre>threadID: ".$threadID." # </pre>";
foreach($t AS $k => $v){
if($f = mysqli_fetch_assoc( mysqli_query($link,"SELECT tag_id FROM xf_tag WHERE tag='".$v['tag']."'") ) ){
echo " tagid_".$f['tag_id']."; ";
}else {
echo "<font color=red> no_tagid_found: ".$v['tag']."; </font>";
unset($t[$k]); //remove not existing tag
}
}
$tx = serialize($t);
if($row['tagx']!=$tx){
//update
$q = "UPDATE xf_thread SET tags='$tx' WHERE thread_id='$threadID' LIMIT 1";
if(mysqli_query($link,$q)){ echo "-!!-"; }else{ echo "-EE-"; }
echo "<br />".$tx;
echo "<br />".$row['tagx'];
}else{
echo "---ident!";
}
echo "<hr />";
}
$page++;
echo "<a href='?p=$page'>NEXT PAGE</a><meta http-equiv=refresh content='1,?p=$page' />";