0

i want to create a search functioanlity for my real estate website.here i have created search criteria and to fullfill this criteria i have used a jax call. this ajax will call php file and that file will send data to search page . here is my sample code. i dont know what issue is there. thanks in advnce

  function searchBuy() {
        //alert("search Loaed");
       $.ajax({
        url: 'searchBuyCriteria.php',
        type: 'POST',
        //dataType: "json",
        data: {
            cat: $('#SelectCat').val(),
           MaxArea:$('#SelectMaxArea').val()
        }
        }).success(function(data){
            console.log("Success"+data);
            alert(JSON.stringify(data));
        }).error(function(data){
            console.log("Error"+data);
        });
        } </scipt>

searchCriteria.php

    <?php

    include_once('_secure/conn.php');

    $city = $_POST['SelectCity'];
    $cat= $_POST['SelectCat'];
    $rooms = $_POST['SelectRooms'];
    $minRange = $_POST['SelectMinRange'];
    $maxRange = $_POST['SelectMaxRange'];
    $minArea = $_POST['SelectMinArea'];
    $maxArea = $_POST['SelectMaxArea'];

    $conn=mysql_connect(DB_HOST,DB_USER,DB_PWD,DB_NAME);
    mysql_select_db(DB_NAME);

    $Searchqry ="Select * from tblcategory where category_title like '%".$cat."%' ";
    $searchExec = mysql_query($Searchqry) or die(mysql_error());
    $searchRow = mysql_fetch_array($searchExec);
    //echo $searchRow;
    echo json_encode($searchRow);
?>  

conn.php

<?php 
session_start();    
ob_start();
    if(!isset($path))
        $path="./";
    elseif($path=="")
        $path="../";    

    require_once("settings.inc.php");
    $database='srijanip';
    $user='srijanip';
    $pass='********';
    $host='example.*****.in';

    define("DB_HOST", "$host");
    define("DB_NAME", "$database");
    define("DB_USER", "$user");
    define("DB_PWD", "$pass");
?>
Shadow
  • 33,525
  • 10
  • 51
  • 64
  • remove `ob_start();` and check. And stop using `mysql_*` (deprecated and removed). use `mysqli_*` OR `PDO` – Alive to die - Anant Aug 23 '16 at 09:41
  • remove `ob_start();`, also remove `?>` in both files, make sure no spaces and anything before ` – Thanh Khánh Aug 23 '16 at 09:42
  • @ThanhKhánh why to remove `?>` – Alive to die - Anant Aug 23 '16 at 09:45
  • remove `?>` to make sure you don't send extra spaces after `?>`. If you have any spaces after `?>` and include the file before you call `header("Location : "somepage.php")`, you will get header already sent error. – Thanh Khánh Aug 23 '16 at 09:48
  • a common case to fix that error is check file encoding. Make sure the file encoding is UTF-8 without BOOM. some BOOM at beginning in the file also make that error. – Thanh Khánh Aug 23 '16 at 09:51
  • i have already check the file encode which is utf-8 without BOM @ThanhKhánh and also remove ob_start() but the error remains same . – Mayuri Srijani Aug 23 '16 at 10:09
  • 4
    Possible duplicate of [How to fix "Headers already sent" error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Shadow Aug 23 '16 at 10:16

0 Answers0