• 03-12-2022, 15:42:11
    #1
    Selamlar,

    Wordpress içerisindeki bir eklentiden özel olarak fiyatları çekmek için bir kod bloğu kullanmıştık. Farkettik ki hata logları şişiyor ve nasıl çözeceğimizi bilmiyorum.
    Bu işlem ürün fiyatlarını database'den çekip kullanıcıya gösteriyor. Tabii bazı ürünlerin fiyatları olmuyor. (hata bundan kaynaklı olabilir)

    Sürekli dönen hata kodu aşağıdaki gibidir.

    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'and stock_status>0 and price >0 order by price asc limit 6' at line 1 for query select * from wp_cegg_product where post_id= and stock_status>0 and price >0 order by price asc limit 6
    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'and stock_status>0 and price >0 order by price asc limit 6' at line 1 for query select * from wp_cegg_product where post_id= and stock_status>0 and price >0 order by price asc limit 6
    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'and stock_status>0 and price >0 order by price asc limit 6' at line 1 for query select * from wp_cegg_product where post_id= and stock_status>0 and price >0 order by price asc limit 6
    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'and stock_status>0 and price >0 order by price asc limit 6' at line 1 for query select * from wp_cegg_product where post_id= and stock_status>0 and price >0 order by price asc limit 6
    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query SELECT * FROM wp_posts WHERE ID =
    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query SELECT * FROM wp_posts WHERE ID =
    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query SELECT * FROM wp_posts WHERE ID =
    [03-Dec-2022 11:14:39 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 for query SELECT * FROM wp_posts WHERE ID =
    Kullandığımız ve hata veren kod bloğu ise şöyle:

    <?php
    
    $fiyatlar1 = $wpdb->get_results("select * from wp_cegg_product where post_id=".$_GET['g1']." and stock_status>0 and price >0 order by price asc limit 6", OBJECT);
    
    $fiyatlar2 = $wpdb->get_results("select * from wp_cegg_product where post_id=".$_GET['g2']." and stock_status>0 and price >0 order by price asc limit 6", OBJECT);
    $fiyatlar3 = $wpdb->get_results("select * from wp_cegg_product where post_id=".$_GET['g3']." and stock_status>0 and price >0 order by price asc limit 6", OBJECT);
    $fiyatlar4 = $wpdb->get_results("select * from wp_cegg_product where post_id=".$_GET['g4']." and stock_status>0 and price >0 order by price asc limit 6", OBJECT);
    
    $detay[0] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = ".$_GET['g1'] ) );
    $detay[1] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = ".$_GET['g2'] ) );
    $detay[2] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = ".$_GET['g3'] ) );
    $detay[3] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = ".$_GET['g4'] ) );
    
    
    $fiyatlar = array(
        "fiyatlar1" => @$fiyatlar1,
        "fiyatlar2" => @$fiyatlar2,
        "fiyatlar3" => @$fiyatlar3 ,
        "fiyatlar4" => @$fiyatlar4
    );
    $wp_root_path = str_replace('/wp-content/themes', '', get_theme_root());
    
    $dir    = $wp_root_path.'/wp-content/uploads/urun-logolari';
    $files1 = scandir($dir);
    $tel[0] = $_GET['g1'];
    $tel[1] = $_GET['g2'];
    $tel[2] = $_GET['g3'];
    $tel[3] = $_GET['g4'];
    
    ?>
    Çok teşekkürker.
    Sevgiler.
  • 03-12-2022, 15:47:01
    #2
    PHP sürüm ile alakalı hocam ve sisteminiz mariadb ise msql kullanmanız gerekiyor ama msql ise mariadb gerekiyor PHP ayarlarınızı düzenlemeniz gerekiyor
  • 03-12-2022, 15:48:46
    #3
    Mysql kullanamıyoruz çünkü bazı özel yazdığımız şeyler çalışmıyor. Sadece MariaDB'de çalışıyor.
    Bu hatanın da aslında bi zararı yok. Sistem çalışıyor. Sadece logları sürekli şişiriyor. MariaDB ile bu sorunu çözemez miyiz ? PHP ayarlarından kastın nedir ek olarak ?
  • 03-12-2022, 16:13:15
    #4
    g1, g2, g3 veya g4 verileri gelmediğinden dolayı hata veriyor
    isset ve !empty ile get ten gelen verilerin olup olmadığı kontrol ettikten sonra işlemini yaptırın
  • 03-12-2022, 21:09:11
    #5
    trgino adlı üyeden alıntı: mesajı görüntüle
    g1, g2, g3 veya g4 verileri gelmediğinden dolayı hata veriyor
    isset ve !empty ile get ten gelen verilerin olup olmadığı kontrol ettikten sonra işlemini yaptırın
    Kodu söylediğin gibi düzenleme konusunda yardımcı olabilir misin ? O kadar hakim değilim. Yanlış bişey yapmayayım.
  • 18-08-2023, 15:35:36
    #6
    Bu konu hakkında kim yardımcı olabilir. Loglar sürekli şişiyor.