Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.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 使用GET传递GET并读取mySQL_Php_Mysql_Ajax - Fatal编程技术网

Php 使用GET传递GET并读取mySQL

Php 使用GET传递GET并读取mySQL,php,mysql,ajax,Php,Mysql,Ajax,我目前遇到一个bug,需要将参数值从url传递到后端的PHP文件 URL是什么样子的?p=tasks&t=view\u task&id=1。我需要将值为1的id传递到我的页面,该页面位于,即url:'/core/views/task_comments.php' var seconds = 1000; // time in milliseconds var tc_reload = function() { $.ajax({ type: 'GET', url: '/core

我目前遇到一个bug,需要将参数值从url传递到后端的
PHP
文件

URL是什么样子的
?p=tasks&t=view\u task&id=1
。我需要将值为
1
id
传递到我的页面,该页面位于,即
url:'/core/views/task_comments.php'

var seconds = 1000; // time in milliseconds
var tc_reload = function() {
   $.ajax({
     type: 'GET',
     url: '/core/views/task_comments.php',
     data: {id: id},
     cache: false,
     success: function(data) {
       $('#task-comments').html(data);
       setTimeout(function() {
         tc_reload();
       }, seconds);
     }
   });
 };
 tc_reload();
在PHP页面上,我得到了以下代码

// Fetch task data
$task_fetch = $conn->prepare("SELECT * FROM system_tasks WHERE task_id = :task_id");
$task_fetch->bindValue(":task_id", $_GET['id'], PDO::PARAM_INT);
$task_fetch->execute();
我收到的是以下错误

注意:第19行C:\xampp\htdocs\core\views\task\u comments.php中的未定义索引:id`

我很想知道哪里出了问题,解决了这个问题

显然,config.php文件在id参数之后添加了
?p=login

url:'/core/views/task\u comments.php?id='+id+'&p=login'
修复了这个问题,它现在可以正常工作了。

在代码中定义
id
的地方???应该是
id
而不是
task\u id
。更新了代码@Saty@Samuel是否设置了id的javascript值?
id
在url中定义,
?p=tasks&t=view\u task&id=1
。难道我不能将
GET
参数值发送到
PHP
页面吗@因为在AJAX调用中没有发送
p
t
参数。