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.