Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 603085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:53:34+00:00 2026-05-13T16:53:34+00:00

I created a search facility with ExtJS and PHP. The PHP file is the

  • 0

I created a search facility with ExtJS and PHP. The PHP file is the server side script with communicates with the database. On my Linux Environment, its working flawlessly. However, since I need to install this application on a Windows Server, I tried to copy it to my personal Windows XP.

I installed Apache, PHP with the necessary extensions, and MySQL. The logon screen loads and the authentication works. When you are authenticated, the application loads the data successfully (the data is information about people; idcard, etc…).

The problem occurs whenever I try to search. When I searched on the Linux envirnoment, it was working, now Firebug shows me the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'am' in 'where clause'

I don’t have any column ‘am’. The most similar to this is the NAME column. I tried removing chunks of code from the php file to isolate the problem but all was in vain.

Do you have any idea why the search is not working on Windowos but its working on Linux?

Here is the code for the php file:

function regexp($search, $value) {
// case insensitive hard coded
return @preg_match("/$search/i", $value); 
}

function concat_ws() {
    $args = func_get_args();
    $sep = array_shift($args);
    return implode($sep, $args);
} // eo function concat_ws

 function quote_array(&$val, $key, $quot = '"') {
    $quot_right = array_key_exists(1, (array) $quot) ? $quot[1] : $quot[0];
    $val = is_null($val) ? "null" : $quot[0] . preg_replace("/'/", "''", $val) .    $quot_right;
}

class csql {

public function getLastTable() {

$sql  = "SELECT table_name, create_time FROM information_schema.TABLES WHERE table_schema = 'mydbname' ORDER BY CREATE_TIME desc LIMIT 1";

$ostmt = $this->odb->query($sql);
$tableArray = $ostmt->fetchAll(PDO::FETCH_OBJ);

$table = $tableArray[0]->table_name;

return $table;

}

// protected functions
protected function getOdb($engine) {
    switch($engine) {
        case "sqlite":
            if("/" !== $file[0]) {
                $file = realpath(".") . "/$file";
            }
            $odb = new PDO("sqlite:$file");
            $odb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $odb->sqliteCreateFunction("regexp", "regexp", 2);
            $odb->sqliteCreateFunction("concat_ws", "concat_ws");
        break;

        case "mysql";
            $hostname = 'localhost';
            $username = 'myuser';
            $password = 'mypass';
            $odb = new PDO("mysql:host=$hostname;dbname=mydbname", $username, $password);
            $odb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        break;
    }

    return $odb;
} 

protected function getWhere($params) {

    $where = isset($where) ? "where $where" : "";

    $query = "";

    if($query && is_array($search) && sizeof($search)) {
        $a = array();
        foreach($search as $f) {
            $a[] = "$f regexp '$query'";
        }
        $where .= $where ? " and(" : "where (";
        $where .= implode(" or ", $a) . ")";
    }

    return $where;

} 

public function __construct($engine = "mysql") {
    $this->odb = $this->getOdb($engine);
} 

public function getCount($params) {

    // params to variables
    extract($params);

    $selectedFields = $_POST['fields'];

    $selectedFields = explode(",", $selectedFields);


    $count = 0;
    foreach ($selectedFields as $selectedField)
    {

        if ($count == 0)
        {
            $selectedField = substr_replace($selectedField, "", 0, 3);
            $selectedField= substr_replace($selectedField, "", -2);

            $selectedFields[0] = $selectedField;
        }

        else if ($count == count($selectedFields)-1)
        {
            $selectedField = substr_replace($selectedField, "", 0, 2);
            $selectedField = substr_replace($selectedField, "", -3);

            $selectedFields[count($selectedFields)-1] = $selectedField;
        }
        else
        {
            $selectedField = substr_replace($selectedField, "", 0, 2);
            $selectedField = substr_replace($selectedField, "", -2);

            $selectedFields[$count] = $selectedField;
        }

        $count++;
    }

    if ($count == 1)
    {
        $selectedFields[0] = substr_replace($selectedFields[0], "", -1);
    }

    if ($_POST['fields'] == "")
    {
        $like = "";
        foreach ($fields as $field)
        {
            $like = $like . $field . " LIKE '%" . $query . "%' or ";    

        }
        $like = substr_replace($like, "", -3);

    }
    else
    {
        $queryExploded = explode(" ", $query);

        $fullLike = "";

        foreach ($queryExploded as $explode)
        {
            foreach ($selectedFields as $selectedField)
            {
                $fullLike = $fullLike . " " . $selectedField . " LIKE '%" . $explode . "%' OR ";
            }

            $fullLike = substr_replace($fullLike, ") AND (", -3);

        }
        $fullLike = substr_replace($fullLike, "", -5);

    }

    $count = null;

    if ($_POST['fields'] == "")
    {
        $ostmt = $this->odb->prepare("select count(*) from {$params['table']} " . $this->getWhere($params));
    }
    else
    {
        $ostmt = $this->odb->prepare("select count(*) from {$params['table']} where (" . $fullLike . $this->getWhere($params));
    }

    $ostmt->bindColumn(1, $count);
    $ostmt->execute();
    $ostmt->fetch();
    return (int) $count;

} 

public function getData($params) {

    $fullLike = "";
    // params to variables
    extract($params);
    $selectedFields = $_POST['fields'];
    $selectedFields = explode(",", $selectedFields);

    $count = 0;
    foreach ($selectedFields as $selectedField)
    {

        if ($count == 0)
        {
            $selectedField = substr_replace($selectedField, "", 0, 3);
            $selectedField= substr_replace($selectedField, "", -2);

            $selectedFields[0] = $selectedField;
        }
        else if ($count == count($selectedFields)-1)
        {
            $selectedField = substr_replace($selectedField, "", 0, 2);
            $selectedField = substr_replace($selectedField, "", -3);

            $selectedFields[count($selectedFields)-1] = $selectedField;
        }
        else
        {
            $selectedField = substr_replace($selectedField, "", 0, 2);
            $selectedField = substr_replace($selectedField, "", -2);

            $selectedFields[$count] = $selectedField;
        }
        $count++;
    }

    if ($count == 1)
    {
        $selectedFields[0] = substr_replace($selectedFields[0], "", -1);
    }

    if ($_POST['fields'] == "")
    {
        $like = "";
        foreach ($fields as $field)
        {
            $like = $like . $field . " LIKE '%" . $query . "%' or ";    

        }
        $like = substr_replace($like, "", -3);  
    }
    else
    {
        $queryExploded = explode(" ", $query);

        $fullLike = "";

        foreach ($queryExploded as $explode)
        {
            foreach ($selectedFields as $selectedField)
            {
                $fullLike = $fullLike . " " . $selectedField . " LIKE '%" . $explode . "%' OR ";
            }

            $fullLike = substr_replace($fullLike, ") AND (", -3);

        }

        $fullLike = substr_replace($fullLike, "", -5);
    }

    $sql  = "select * ";
    //$sql .= implode(",", $fields);
    if ($fullLike == "")
    {
        $sql .= " from $table";
    }
    else
    {
        $sql .= " from $table where  (" . $fullLike . $this->getWhere($params);
    }
    $sql .= isset($groupBy) && $groupBy ? " group by $groupBy" : "";

    if(!is_null($sort)) {
        $sql .= " order by $sort";
        $sql .= is_null($dir) ? "" : " $dir";
    }
    if(!is_null($start) && !is_null($limit)) {
        $sql .= " limit $start,$limit";
    }


    $ostmt = $this->odb->query($sql);

    return $ostmt->fetchAll(PDO::FETCH_OBJ);

}

This code was a sample from ExtJS. I modified it a lot. However, I though the source of the problem was from the getWhere function. However, I tried removing it and the code still remained there.

I have been struggling for the last 24 hours with this problem. The only ‘solution’ I found was to create the database with duplicate fields. Here is the reason:

When the ExtJS form first loads, the columns are correct, i.e. name, idcard, etc… Whenever I start searching, the first and last letter of the column name disappears, which means they become like this: am, dcar, etc…

What I’ve done is to create duplication columns for name, idcard, etc… naming them am, dcar, etc…

I know this is a lot of duplication of data but I cant understand why this is happening only on Windows! It sucks!

Many Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:53:34+00:00Added an answer on May 13, 2026 at 4:53 pm

    Do some code isolation to narrow down the problem.

    Create a new PHP file. Copy ONLY the search code into it. Run the php file through your browser (not the extjs code). Does it fail the same way?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 368k
  • Answers 368k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Entity Framework designer is terrible - I've had the… May 14, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer If by "hijack" you meant sniff the packets then what… May 14, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer If you want two actions to be atomic, embed them… May 14, 2026 at 5:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.