Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jquery自动完成源代码访问问题 我正在做一个CMS作为一个项目。_Php_Jquery_.htaccess_Autocomplete - Fatal编程技术网

Php jquery自动完成源代码访问问题 我正在做一个CMS作为一个项目。

Php jquery自动完成源代码访问问题 我正在做一个CMS作为一个项目。,php,jquery,.htaccess,autocomplete,Php,Jquery,.htaccess,Autocomplete,我想能够搜索一个用户,它自动完成从数据库的结果 我已经在一页上完成了这项工作 但是我的CMS似乎不想让它工作 我使用的结构是: 管理 -index.php -页数 -moduals.php 页 -页数 -page.php index.php 在管理和主索引文件中,我设置了一个包含系统 所以如果你转到domain.tld/admin/user 它实际上会将您带到admin/index.php?page=user htaccess文件如下所示: RewriteEngine on RewriteRul

我想能够搜索一个用户,它自动完成从数据库的结果

我已经在一页上完成了这项工作

但是我的CMS似乎不想让它工作

我使用的结构是: 管理 -index.php -页数 -moduals.php 页 -页数 -page.php index.php

在管理和主索引文件中,我设置了一个包含系统

所以如果你转到domain.tld/admin/user 它实际上会将您带到admin/index.php?page=user

htaccess文件如下所示:

RewriteEngine on
RewriteRule ^admin/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ admin/?page=$1&task=$2&id=$3
RewriteRule ^admin/([^/\.]+)/([^/\.]+)/?$ admin/?page=$1&id=$2
RewriteRule ^admin/([^/\.]+)/?$ admin/?page=$1
RewriteRule ^admin/ admin/index.php
RewriteRule ^profile/([^/\.]+)/?$ index.php?page=profile&name=$1
RewriteRule ^hardware/([^/\.]+)/?$ index.php?page=hardware&name=$1
RewriteRule ^activate/([^/\.]+)/?$ index.php?page=activate&akey=$1
RewriteRule ^([^/\.]+)/?$ index.php?page=$1
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&id=$2
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&id=$2&title=$3


<Files ~ "^\.ht">
 Order allow,deny
 Deny from all
 Satisfy All
</Files>

<IfModule mod_deflate.c>
    # Compress HTML, plain text, CSS and JavaScript
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/x-javascript

    # Avoid problems in problematic browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/x-icon "access plus 2 weeks"
    ExpiresByType application/x-javascript "access plus 2 weeks"
    ExpiresByType text/javascript "access plus 2 weeks"
    ExpiresByType text/css "access plus 2 weeks"
    ExpiresByType image/gif "access plus 2 weeks"
    ExpiresByType image/png "access plus 2 weeks"
    ExpiresByType image/jpeg "access plus 2 weeks"
    ExpiresByType application/pdf "access plus 2 weeks"
</IfModule>
<?
define('DB_SERVER', 'XXXXX');
define('DB_USER', 'XXXXX');
define('DB_PASSWORD', 'XXXXX');
define('DB_NAME', 'XXXX');


if (isset($_GET['term'])){
    $return_arr = array();

    try {
        $conn = new PDO("mysql:host=".DB_SERVER.";port=8889;dbname=".DB_NAME, DB_USER, DB_PASSWORD);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        $stmt = $conn->prepare('SELECT username FROM user WHERE username LIKE :term');
        $stmt->execute(array('term' => '%'.$_GET['term'].'%'));

        while($row = $stmt->fetch()) {
            $return_arr[] =  $row['username'];
        }

    } catch(PDOException $e) {
        echo 'ERROR: ' . $e->getMessage();
    }


    /* Toss back results as json encoded array. */
    echo json_encode($return_arr);
}

?>
重新编写引擎打开
重写规则^admin/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$admin/?page=$1&task=$2&id=$3
重写规则^admin/([^/\.]+)/([^/\.]+)/?$admin/?page=$1&id=$2
重写规则^admin/([^/\.]+)/?$admin/?页面=$1
重写规则^admin/admin/index.php
重写规则^profile/([^/\.]+)/?$index.php?page=profile&name=1
重写规则^hardware/([^/\.]+)/?$index.php?page=hardware&name=1
重写规则^activate/([^/\.]+)/?$index.php?page=activate&akey=1
重写规则^([^/\.]+)/?$index.php?页面=$1
重写规则^([^/\.]+)/([^/\.]+)/?$index.php?页面=$1&id=$2
重写规则^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$index.php?页面=$1&id=$2&title=$3
命令允许,拒绝
全盘否定
满足所有
#压缩HTML、纯文本、CSS和JavaScript
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript应用程序/x-javascript
#避免在有问题的浏览器中出现问题
浏览器匹配^Mozilla/4 gzip纯文本/html
浏览器匹配^Mozilla/4\.0[678]无gzip
BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
过期于
ExpiresByType图像/x图标“访问加2周”
ExpiresByType应用程序/x-javascript“访问加2周”
ExpiresByType文本/javascript“访问加2周”
ExpiresByType文本/css“访问加2周”
ExpiresByType image/gif“访问加2周”
ExpiresByType image/png“访问加2周”
过期按类型图像/jpeg“访问加2周”
过期按类型应用程序/pdf“访问加2周”
我正在使用自动完成文件的页面的代码是:

    <form action='' method='post'>
        <p><label>username:</label><input type='text' name='username' value='' class='auto'></p>
    </form>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>    
<script type="text/javascript">
$(function() {

    //autocomplete
    $(".auto").autocomplete({
        source: "jquser.php",
        minLength: 2
    });                

});
</script>

用户名:

$(函数(){ //自动完成 $(“.auto”).autocomplete({ 来源:“jquser.php”, 最小长度:2 }); });
jquser.php文件与teams.php文件位于同一个文件中

jquser.php文件如下所示:

RewriteEngine on
RewriteRule ^admin/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ admin/?page=$1&task=$2&id=$3
RewriteRule ^admin/([^/\.]+)/([^/\.]+)/?$ admin/?page=$1&id=$2
RewriteRule ^admin/([^/\.]+)/?$ admin/?page=$1
RewriteRule ^admin/ admin/index.php
RewriteRule ^profile/([^/\.]+)/?$ index.php?page=profile&name=$1
RewriteRule ^hardware/([^/\.]+)/?$ index.php?page=hardware&name=$1
RewriteRule ^activate/([^/\.]+)/?$ index.php?page=activate&akey=$1
RewriteRule ^([^/\.]+)/?$ index.php?page=$1
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&id=$2
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&id=$2&title=$3


<Files ~ "^\.ht">
 Order allow,deny
 Deny from all
 Satisfy All
</Files>

<IfModule mod_deflate.c>
    # Compress HTML, plain text, CSS and JavaScript
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/x-javascript

    # Avoid problems in problematic browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/x-icon "access plus 2 weeks"
    ExpiresByType application/x-javascript "access plus 2 weeks"
    ExpiresByType text/javascript "access plus 2 weeks"
    ExpiresByType text/css "access plus 2 weeks"
    ExpiresByType image/gif "access plus 2 weeks"
    ExpiresByType image/png "access plus 2 weeks"
    ExpiresByType image/jpeg "access plus 2 weeks"
    ExpiresByType application/pdf "access plus 2 weeks"
</IfModule>
<?
define('DB_SERVER', 'XXXXX');
define('DB_USER', 'XXXXX');
define('DB_PASSWORD', 'XXXXX');
define('DB_NAME', 'XXXX');


if (isset($_GET['term'])){
    $return_arr = array();

    try {
        $conn = new PDO("mysql:host=".DB_SERVER.";port=8889;dbname=".DB_NAME, DB_USER, DB_PASSWORD);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        $stmt = $conn->prepare('SELECT username FROM user WHERE username LIKE :term');
        $stmt->execute(array('term' => '%'.$_GET['term'].'%'));

        while($row = $stmt->fetch()) {
            $return_arr[] =  $row['username'];
        }

    } catch(PDOException $e) {
        echo 'ERROR: ' . $e->getMessage();
    }


    /* Toss back results as json encoded array. */
    echo json_encode($return_arr);
}

?>

现在,如果我删除htaccess文件,它可以工作,但它不能与htaccess文件一起工作,我想这是重写规则

有人能帮我吗?这可能很简单,但由于某种原因,我愚蠢的大脑无法处理它

很抱歉,我想提供尽可能多的信息

提前感谢你的帮助