Server 400 bad request(yomon xatolik)

+1 ovoz
68 marta ko‘rilgan
so‘radi 04 dekabr, 18 parmonov98 (1,267 bal)
teglar o‘zgartirildi 24 dekabr, 18 Saidolim

#savol  so'rovdan shunday javob qaytmoqda /ajax/search.php?query=matn Failed to load resource: the server responded with a status of 400 ()
js da. Apache.
 

RewriteEngine On
AddDefaultCharset utf-8
ErrorDocument 404 https://www.domain.uz/uz/page/404/
#<FilesMatch "robots.txt$">
#RewriteEngine off
#</FilesMatch>

#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^ajax/search.php
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]

php_flag  display_errors        off

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ /?mainurl=$1 [QSA,L]

yana nimadan bo'lishi mumkin? 

izoh qoldirdi 05 dekabr, 18 MasterC (9 bal)
ko‘chirildi 05 dekabr, 18 Saidolim

Bu apache dan emas siz ishlatayotgan frameworkdan bo'lishi mumkin, /ajax/search.php?query=matn controller ini ko'rsata olasizmi?

izoh qoldirdi 08 dekabr, 18 parmonov98 (1,267 bal)
<?php

require_once "connection.php";


if(isset($_GET['query'])){
    $search = new search();
   

    $string = is_string($_GET['query'])?$_GET['query']:false;
    $result = $search->search_posts('uz', $string);

   

    $matchpost[][] = 0;

    for($i = 0; $i < count($result); $i++){
    $matchpost[$i][]++;
    if(isset($result[$i][1])){
        unset($result[$i]);
    }

    echo "<div class='flex flex-space middle search-item' style='* {padding: 5px;}'>";     
    echo '<i class="fa fa-newspaper-o" title="maqola" aria-hidden="true"></i>';
    echo "<img class='result-img' src='https://www.domain.uz/open/imgs/".$result[$i]['post_img']."' width='25' height='25'>";   
    echo "<p> <author>".$result[$i]['post_author'].": </author><a href='https://www.domain.uz/uz/post/".$result[$i]['post_link'].".py'>" .$result[$i]['post_title']." </a></p>";
    echo "</div>";   
    }

   
   
}else{
   
    echo 2;

}


class search{
    private $conn;

     function __construct(){
       
        $this->conn = new connection();
       
     }
     

     
     function explode_string($str){
         return $result = explode(' ',  $str);
         
     }
     // searching posts by keywords LIKE searchingg
     function search_posts(string $lang = 'uz', string $items){
         $items = $this->explode_string($items);
         
         $subquery = "";
                for($i = 0; $i < count($items); $i++){
                    $subquery .= "pt.post_tags LIKE "."'%".$items[$i]."% ' OR ";
                    if(isset($items['keywords'][$i+1]))
                        $subquery .= "pt.post_tags LIKE "."'%".$items[$i].$items[$i+1]."% ' OR ";
                    $subquery .= "pt.post_description LIKE "."'%".$items[$i]."%' OR ";
                    if(isset($items[$i+1]))
                        $subquery .= "pt.post_description LIKE "."'%".$items[$i].$items[$i+1]."%' OR ";
                   
                    $subquery .= "pt.post_title LIKE "."'%".$items[$i]."%' OR ";
                    if(isset($items['keywords'][$i+1]))
                        $subquery .= "pt.post_title LIKE "."'%".$items[$i].$items[$i+1]."%' OR ";
                }
                $subquery = rtrim($subquery, ' OR ');
                #$subquery .= ")";
                $lang = 'uz';
                "SELECT distinct ct.id, ct.cat_title, ct.cat_link, pt.id,
                       pt.post_title, pt.post_link, pt.post_author, pt.post_img, pt.post_date, pt.post_cat_id
                FROM `cates_of_site` as ct, en_posts_of_site as pt
                WHERE (
                  pt.post_tags LIKE '%hello%' OR
                  pt.post_tags LIKE '%hi%' OR
                  pt.post_description LIKE '%hello%' OR
                  pt.post_description LIKE '%hi%'
                ) AND ct.id = pt.post_cat_id
                ";


                $sql = "SELECT distinct ct.id,  ct.cat_link, pt.id,
                 pt.post_title,    pt.post_link, pt.post_author, pt.post_img,pt.post_date, pt.post_cat_id
                FROM `cates_of_site` as ct, `".$lang."_posts_of_site` as pt,
                `".$lang."_cat_info` as lng_ct, `".$lang."_subcates_of_site` as sub_ct
                WHERE sub_ct.subcat_id = pt.post_cat_id AND ct.id = sub_ct.parent_id AND  (".$subquery.")     ";
               
                "
                SELECT distinct ct.id, ct.cat_link, pt.id, pt.post_title, pt.post_link, pt.post_author,
                pt.post_img,pt.post_date, pt.post_cat_id FROM `cates_of_site` as ct,
                `uz_subcates_of_site` as sub_ct, `uz_posts_of_site` as pt, `uz_cat_info` as lng_ct
                WHERE sub_ct.subcat_id = pt.post_cat_id AND ct.id = sub_ct.parent_id AND
                (pt.post_tags LIKE '%ht% ' OR pt.post_description LIKE '%ht%' OR pt.post_title LIKE '%ht%')
                ";
               
               
            return $this->conn->select($sql);
     }
     
}

?>

2 Javoblar

0 ovoz
javob berdi 13 dekabr, 18 MasterC (9 bal)
apache dan ajax/search.php ga bog'liq xamma narsalarni olib tashlang
izoh qoldirdi 18 dekabr, 18 parmonov98 (1,267 bal)
barchasini olib tashladim, foydasi bo'lmadi.
izoh qoldirdi 18 dekabr, 18 MasterC (9 bal)
unda jo'natgan requestingizda xato bor. uni ham ko'rsata olasizmi?
izoh qoldirdi 23 dekabr, 18 parmonov98 (1,267 bal)
aka, bo'ldi hal bo'ldi. lekin berilgan kodlarda jo'natiladigan so'rovlar ko'rsatilgandi lekin
0 ovoz
javob berdi 21 dekabr, 18 Jasur320 (59 bal)
"search" class da $conn private deb e'lon qilingan ekan, shuni public qilib ko'rin, ishalashi kerak.
izoh qoldirdi 21 dekabr, 18 Jasur320 (59 bal)
Umuman ishlatgan private variable larizni public qilib ko'rin.
izoh qoldirdi 23 dekabr, 18 parmonov98 (1,267 bal)
nega? $conn  ga faqat class ichidan call bo'lyapti uni ahamiyati yo'q. private class ichidan chaqiruv lar uchun ruxsat beradi.

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...