• 15-12-2007, 02:14:56
    #1
    Bugün sitemdeki adsense pub kodunu değiştirmem gerekiyordu, daha önceden ilgili tabloyu indirip Advanced Find and Replace programıyla işimi görmüştüm ancak Türkçe karakter sorunuyla epey uğraşmak zorunda kalmıştım. Onun yerine bunu direk mysqlden komut satırıyla yapmak çok daha sorunsuz ve kolay olur diye düşündüm.
    update tablo_ismi set tablo_alanı = replace(tablo_alanı,'Bunu_değiştir','Bununla');
    adsenseden banlandığınız zaman direk sorguyla pub kodlarını değiştirebilirsiniz. Yada ne bilim işte siteyi satarsanız pub kodu değiştirmek isterseniz vs vs
    (domain banlandıysa bildiğiniz gibi bi işe yaramaz)
    Umarım işinize yarar.
  • 15-12-2007, 13:28:26
    #2
    Anlatım için teşekkürler..
  • 10-05-2008, 15:33:59
    #3
    'Bunu_değiştir','Bununla' bu kısmın kaldırıp tablo_alanı kısmını içini komple değiştirmek istesem?
    Yani tablo_alanı diyelimki forumda imzalar tablosu olsun herkesin imzasını tek sorguyla düzenlemiş olurum.Nasıl yapabilirim peki ?

    update kullanicilar set imzalar = replace(imzalar,'Bunu_değiştir','Bununla');
    Bunun yerine tüm imzaları değiştirmek istiyorum.
  • 02-05-2014, 22:55:06
    #4
    Tüm tablolardaki, tüm alanlardaki A kelimesini nasıl B ye çevirebilirim?
    Konuyu hortlattık biraz
  • 03-05-2014, 03:49:44
    #5
    Üyeliği durduruldu
    EmreUnan adlı üyeden alıntı: mesajı görüntüle
    Tüm tablolardaki, tüm alanlardaki A kelimesini nasıl B ye çevirebilirim?
    Konuyu hortlattık biraz
    Aşağıdaki kodlarda db bilgileri ve aranılıp değiştirilcek kelimeleri ayarladıktan sonra siten.com/bul.php diye atıp çalıştır.

    NOT: Bu işlemi yapmadan önce mutlaka veritabanı yedeğini al.

    <?php
    // bul ve değiştir
    
    // burada ara
    $search        = 'aranan-kelime';
    
    // değiştir
    $replace    = 'yeni-kelime';
    
    // db bilgilerin
    $hostname = "localhost";
    $database = "dbadin";
    $username = "dbkullanici";
    $password = "dbpass";
    
    
    $queryType = 'replace';
    
    
    $showErrors = true;
    
    
    // burdan gerisini elleme
    
    if($showErrors) {
    error_reporting(E_ALL);
    ini_set('error_reporting', E_ALL);
    ini_set('display_errors',1);
    }
    
    
    $MJCONN = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
    mysql_select_db($database,$MJCONN);
    
    
    $table_sql = 'SHOW TABLES';
    $table_q = mysql_query($table_sql,$MJCONN) or die("Cannot Query DB: ".mysql_error());
    $tables_r = mysql_fetch_assoc($table_q);
    $tables = array();
    
    do{
    $tables[] = $tables_r['Tables_in_'.strtolower($database)];
    }while($tables_r = mysql_fetch_assoc($table_q));
    
    
    $use_sql = array();
    
    $rowHeading = ($queryType=='replace') ?
    'Replacing ''.$search.'' with ''.$replace.'' in ''.$database."'nnSTATUS    |    ROWS AFFECTED    |    TABLE/FIELD    (+ERROR)n"
    : 'Searching for ''.$search.'' in ''.$database."'nnSTATUS    |    ROWS CONTAINING    |    TABLE/FIELD    (+ERROR)n";
    
    $output = $rowHeading;
    
    $summary = '';
    
    // LOOP THROUGH EACH TABLE
    foreach($tables as $table) {
    // GET A LIST OF FIELDS
    $field_sql = 'SHOW FIELDS FROM '.$table;
    $field_q = mysql_query($field_sql,$MJCONN);
    $field_r = mysql_fetch_assoc($field_q);
    
    // compile + run SQL
    do {
    $field = $field_r['Field'];
    $type = $field_r['Type'];
    
    switch(true) {
    // set which column types can be replaced/searched
    case stristr(strtolower($type),'char'): $typeOK = true; break;
    case stristr(strtolower($type),'text'): $typeOK = true; break;
    case stristr(strtolower($type),'blob'): $typeOK = true; break;
    case stristr(strtolower($field_r['Key']),'pri'): $typeOK = false; break; // do not replace on primary keys
    default: $typeOK = false; break;
    }
    
    if($typeOK) { // Field type is OK ro replacement
    // create unique handle for update_sql array
    $handle = $table.'_'.$field;
    if($queryType=='replace') {
    $sql[$handle]['sql'] = 'UPDATE '.$table.' SET '.$field.' = REPLACE('.$field.',''.$search.'',''.$replace.'')';
    } else {
    $sql[$handle]['sql'] = 'SELECT * FROM '.$table.' WHERE '.$field.' REGEXP(''.$search.'')';
    }
    
    // execute SQL
    $error = false;
    $query = @mysql_query($sql[$handle]['sql'],$MJCONN) or $error = mysql_error();
    $row_count = @mysql_affected_rows() or $row_count = 0;
    
    // store the output (just in case)
    $sql[$handle]['result'] = $query;
    $sql[$handle]['affected'] = $row_count;
    $sql[$handle]['error'] = $error;
    
    // Write out Results into $output
    $output .= ($query) ? 'OK        ' : '--        ';
    $output .= ($row_count>0) ? '<strong>'.$row_count.'</strong>            ' : '<span style="color:#CCC">'.$row_count.'</span>            ';
    $fieldName = '`'.$table.'`.`'.$field.'`';
    $output .= $fieldName;
    $erTab = str_repeat(' ', (60-strlen($fieldName)) );
    $output .= ($error) ? $erTab.'(ERROR: '.$error.')' : '';
    
    $output .= "n";
    }
    }while($field_r = mysql_fetch_assoc($field_q));
    }
    
    // write the output out to the page
    echo '<pre>';
    echo $output."n";
    echo '<pre>';
    ?>
  • 04-05-2014, 15:48:33
    #6
    Gibberring adlı üyeden alıntı: mesajı görüntüle
    Aşağıdaki kodlarda db bilgileri ve aranılıp değiştirilcek kelimeleri ayarladıktan sonra siten.com/bul.php diye atıp çalıştır.

    NOT: Bu işlemi yapmadan önce mutlaka veritabanı yedeğini al.

    <?php
    // bul ve değiştir
    
    // burada ara
    $search        = 'aranan-kelime';
    
    // değiştir
    $replace    = 'yeni-kelime';
    
    // db bilgilerin
    $hostname = "localhost";
    $database = "dbadin";
    $username = "dbkullanici";
    $password = "dbpass";
    
    
    $queryType = 'replace';
    
    
    $showErrors = true;
    
    
    // burdan gerisini elleme
    
    if($showErrors) {
    error_reporting(E_ALL);
    ini_set('error_reporting', E_ALL);
    ini_set('display_errors',1);
    }
    
    
    $MJCONN = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
    mysql_select_db($database,$MJCONN);
    
    
    $table_sql = 'SHOW TABLES';
    $table_q = mysql_query($table_sql,$MJCONN) or die("Cannot Query DB: ".mysql_error());
    $tables_r = mysql_fetch_assoc($table_q);
    $tables = array();
    
    do{
    $tables[] = $tables_r['Tables_in_'.strtolower($database)];
    }while($tables_r = mysql_fetch_assoc($table_q));
    
    
    $use_sql = array();
    
    $rowHeading = ($queryType=='replace') ?
    'Replacing ''.$search.'' with ''.$replace.'' in ''.$database."'nnSTATUS    |    ROWS AFFECTED    |    TABLE/FIELD    (+ERROR)n"
    : 'Searching for ''.$search.'' in ''.$database."'nnSTATUS    |    ROWS CONTAINING    |    TABLE/FIELD    (+ERROR)n";
    
    $output = $rowHeading;
    
    $summary = '';
    
    // LOOP THROUGH EACH TABLE
    foreach($tables as $table) {
    // GET A LIST OF FIELDS
    $field_sql = 'SHOW FIELDS FROM '.$table;
    $field_q = mysql_query($field_sql,$MJCONN);
    $field_r = mysql_fetch_assoc($field_q);
    
    // compile + run SQL
    do {
    $field = $field_r['Field'];
    $type = $field_r['Type'];
    
    switch(true) {
    // set which column types can be replaced/searched
    case stristr(strtolower($type),'char'): $typeOK = true; break;
    case stristr(strtolower($type),'text'): $typeOK = true; break;
    case stristr(strtolower($type),'blob'): $typeOK = true; break;
    case stristr(strtolower($field_r['Key']),'pri'): $typeOK = false; break; // do not replace on primary keys
    default: $typeOK = false; break;
    }
    
    if($typeOK) { // Field type is OK ro replacement
    // create unique handle for update_sql array
    $handle = $table.'_'.$field;
    if($queryType=='replace') {
    $sql[$handle]['sql'] = 'UPDATE '.$table.' SET '.$field.' = REPLACE('.$field.',''.$search.'',''.$replace.'')';
    } else {
    $sql[$handle]['sql'] = 'SELECT * FROM '.$table.' WHERE '.$field.' REGEXP(''.$search.'')';
    }
    
    // execute SQL
    $error = false;
    $query = @mysql_query($sql[$handle]['sql'],$MJCONN) or $error = mysql_error();
    $row_count = @mysql_affected_rows() or $row_count = 0;
    
    // store the output (just in case)
    $sql[$handle]['result'] = $query;
    $sql[$handle]['affected'] = $row_count;
    $sql[$handle]['error'] = $error;
    
    // Write out Results into $output
    $output .= ($query) ? 'OK        ' : '--        ';
    $output .= ($row_count>0) ? '<strong>'.$row_count.'</strong>            ' : '<span style="color:#CCC">'.$row_count.'</span>            ';
    $fieldName = '`'.$table.'`.`'.$field.'`';
    $output .= $fieldName;
    $erTab = str_repeat(' ', (60-strlen($fieldName)) );
    $output .= ($error) ? $erTab.'(ERROR: '.$error.')' : '';
    
    $output .= "n";
    }
    }while($field_r = mysql_fetch_assoc($field_q));
    }
    
    // write the output out to the page
    echo '<pre>';
    echo $output."n";
    echo '<pre>';
    ?>
    Parse error: syntax error, unexpected T_VARIABLE in /home/ophell/public_html/bul.php on line 5

    Bulamadım hatayı
  • 04-05-2014, 15:58:09
    #7
    Üyeliği durduruldu
    EmreUnan adlı üyeden alıntı: mesajı görüntüle
    Parse error: syntax error, unexpected T_VARIABLE in /home/ophell/public_html/bul.php on line 5

    Bulamadım hatayı

    Satır 5 ve 6 yı şu kısmı düzenler misin?

    $search = 'aranan-kelime';
    
    $replace = 'yeni-kelime';
  • 04-05-2014, 16:15:11
    #8
    Gibberring adlı üyeden alıntı: mesajı görüntüle
    Satır 5 ve 6 yı şu kısmı düzenler misin?

    $search = 'aranan-kelime';
    
    $replace = 'yeni-kelime';

    Parse error: syntax error, unexpected T_STRING in /home/ophell/public_html/bul.php on line 13

    e geldik