• 07-03-2018, 10:49:25
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Merhaba arkadaşlar..
    Wordpress sitemin botu eskiden normal çalışıyordu. Sonra sunucu çökünce yenisini ubuntu 16.xx kurunca php7 kurulmuş dikkat etmemişim. Botum çalışmadı. Akabinde mysqli olarak bir iki şey düzenleyince çalıştı ama bu sefer de aynı yazıyı birkaç kere eklemeye başladı. Eskiden güncellendi oluyordu eklemiyordu. Bana yardım edebilecek var mı acaba?

    // 1. Create a database connection
    $connection = mysqli_connect("localhost","xxxxxxxxxxxxxxx","xxxxxxxxxxxxxxx");
    if (!$connection) {
        die("Database connection failed: " . mysqli_error());
    }
    // 2. Select a database to use 
    $db_select = mysqli_select_db($connection, "xxxxxxxxxxxxxxx");
    if (!$db_select) {
        die("Database selection failed: " . mysqli_error());
    }
      
      
      
      
      
    $query = "select ID from xxx_posts WHERE post_excerpt='$basligim'";
    $sonuc = @mysqli_query($query,$connection);
    if(@mysqli_num_rows($sonuc)==0){
    
    $insert_post = array();
    $insert_post['post_title'] = $basligim;
    $insert_post['post_content'] = $aciklama;
    $insert_post['tags_input'] = $tetiket;
    $insert_post['post_status'] = 'publish';
    $insert_post['post_author'] = 1;
    $insert_post['post_category'] = array(1584);
    $pid = wp_insert_post($insert_post);
    mysqli_query("UPDATE xxx_posts SET post_content='$aciklama' WHERE ID='$pid'");
    $tarih=date("Y-m-d H:i:s");
    mysqli_query("UPDATE xxx_posts SET post_modified='$tarih' WHERE ID='$pid'");
    add_post_meta($pid, 'imagelink', $imagelinkana);
    add_post_meta($pid, 'gorbaslik', $gorbaslik);
    
    echo '<center>'.$basligim.' <b>Eklendi.</b></center>';
    }else{
    $query = mysqli_query("SELECT from xxx_posts WHERE post_excerpt='$basligim'");
    $pid = $result2[0];
    mysqli_query("UPDATE xxx_posts SET post_content='$aciklama' WHERE ID='$pid'");
    mysqli_query("SELECT * FROM xxx_posts WHERE post_excerpt = '$basligim'");
    update_post_meta($pid, 'imagelink', $imagelinkana);
    update_post_meta($pid, 'gorbaslik', $gorbaslik);
    
    echo '<center>'.$basligim.' <b>Guncellendi.</b></center>';}
    $aciklama = '';
    flush();
    ob_get_contents();
    ob_flush();
    }
    ?>
  • 07-03-2018, 11:10:48
    #2
    Azok adlı üyeden alıntı: mesajı görüntüle
    Merhaba arkadaşlar..
    Wordpress sitemin botu eskiden normal çalışıyordu. Sonra sunucu çökünce yenisini ubuntu 16.xx kurunca php7 kurulmuş dikkat etmemişim. Botum çalışmadı. Akabinde mysqli olarak bir iki şey düzenleyince çalıştı ama bu sefer de aynı yazıyı birkaç kere eklemeye başladı. Eskiden güncellendi oluyordu eklemiyordu. Bana yardım edebilecek var mı acaba?

    // 1. Create a database connection $connection = mysqli_connect("localhost","xxxxxxxxxxxxxxx","xxxx xxxxxxxxxxx"); if (!$connection) { die("Database connection failed: " . mysqli_error()); } // 2. Select a database to use $db_select = mysqli_select_db($connection, "xxxxxxxxxxxxxxx"); if (!$db_select) { die("Database selection failed: " . mysqli_error()); } $query = "select ID from xxx_posts WHERE post_excerpt='$basligim'"; $sonuc = @mysqli_query($query,$connection); if(@mysqli_num_rows($sonuc)==0){ $insert_post = array(); $insert_post['post_title'] = $basligim; $insert_post['post_content'] = $aciklama; $insert_post['tags_input'] = $tetiket; $insert_post['post_status'] = 'publish'; $insert_post['post_author'] = 1; $insert_post['post_category'] = array(1584); $pid = wp_insert_post($insert_post); mysqli_query("UPDATE xxx_posts SET post_content='$aciklama' WHERE ID='$pid'"); $tarih=date("Y-m-d H:i:s"); mysqli_query("UPDATE xxx_posts SET post_modified='$tarih' WHERE ID='$pid'"); add_post_meta($pid, 'imagelink', $imagelinkana); add_post_meta($pid, 'gorbaslik', $gorbaslik); echo '<center>'.$basligim.' <b>Eklendi.</b></center>'; }else{ $query = mysqli_query("SELECT from xxx_posts WHERE post_excerpt='$basligim'"); $pid = $result2[0]; mysqli_query("UPDATE xxx_posts SET post_content='$aciklama' WHERE ID='$pid'"); mysqli_query("SELECT * FROM xxx_posts WHERE post_excerpt = '$basligim'"); update_post_meta($pid, 'imagelink', $imagelinkana); update_post_meta($pid, 'gorbaslik', $gorbaslik); echo '<center>'.$basligim.' <b>Guncellendi.</b></center>';} $aciklama = ''; flush(); ob_get_contents(); ob_flush(); } ?>
    Basit bir pdo class bulup kullanmanızı öneririm.
  • 07-03-2018, 14:02:20
    #3
    // 1. Create a database connection $connection = mysqli_connect("localhost","xxxxxxxxxxxxxxx","xxxxxxxxxxxxxxx"); if (!$connection) { die("Database connection failed: " . mysqli_error()); } // 2. Select a database to use $db_select = mysqli_select_db($connection, "xxxxxxxxxxxxxxx"); if (!$db_select) { die("Database selection failed: " . mysqli_error()); } global $wpdb; $sor = $wpdb->get_var("select COUNT(ID) from xxx_posts WHERE post_excerpt='$basligim'");  if($sor==0){ $insert_post = array(); $insert_post['post_title'] = $basligim; $insert_post['post_content'] = $aciklama; $insert_post['tags_input'] = $tetiket; $insert_post['post_status'] = 'publish'; $insert_post['post_author'] = 1; $insert_post['post_category'] = array(1584); $pid = wp_insert_post($insert_post); mysqli_query("UPDATE xxx_posts SET post_content='$aciklama' WHERE ID='$pid'"); $tarih=date("Y-m-d H:i:s"); mysqli_query("UPDATE xxx_posts SET post_modified='$tarih' WHERE ID='$pid'"); add_post_meta($pid, 'imagelink', $imagelinkana); add_post_meta($pid, 'gorbaslik', $gorbaslik); echo '<center>'.$basligim.' <b>Eklendi.</b></center>'; }else{ $query = mysqli_query("SELECT from xxx_posts WHERE post_excerpt='$basligim'"); $pid = $result2[0]; mysqli_query("UPDATE xxx_posts SET post_content='$aciklama' WHERE ID='$pid'"); mysqli_query("SELECT * FROM xxx_posts WHERE post_excerpt = '$basligim'"); update_post_meta($pid, 'imagelink', $imagelinkana); update_post_meta($pid, 'gorbaslik', $gorbaslik); echo '<center>'.$basligim.' <b>Guncellendi.</b></center>';} $aciklama = ''; flush(); ob_get_contents(); ob_flush(); } ?>



    Bir de bunu deneyin olacaktır yüksek ihtimalle. Olmazsa bütün sql sorgularını ezsql sınıfına göre (wpde $wpdb değişkeninden tutulu) düzenlemeniz gerekli.