Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.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 未定义的偏移量:1使用mysql\u real\u escape\u字符串($data[0])_Php_Mysql_Offset_Datetimeoffset - Fatal编程技术网

Php 未定义的偏移量:1使用mysql\u real\u escape\u字符串($data[0])

Php 未定义的偏移量:1使用mysql\u real\u escape\u字符串($data[0]),php,mysql,offset,datetimeoffset,Php,Mysql,Offset,Datetimeoffset,再见,伙计们。撇号在我的神经上。请帮帮我!当RESPO列上有一个撇号单词“OFFICE'S”时,我会出现这个错误 我的第14行和第15行是这样的代码,这使得错误行: $month = date("m", strtotime($data[1])); $year = date("Y", strtotime($data[1])); 总结一下my view_reports.php的所有内容: <?php $respo = $_GET['respo']; $data = explode("+",

再见,伙计们。撇号在我的神经上。请帮帮我!当RESPO列上有一个撇号单词“OFFICE'S”时,我会出现这个错误

我的第14行和第15行是这样的代码,这使得错误行:

$month = date("m", strtotime($data[1]));
$year = date("Y", strtotime($data[1]));
总结一下my view_reports.php的所有内容:

<?php
$respo = $_GET['respo'];

$data = explode("+", ($respo));

$month = date("m", strtotime($data[1]));
$year = date("Y", strtotime($data[1]));

$viewrecord = "SELECT dv.*, dv.respo, (pr.pr_gsis_c + pr.pr_gsis_l) AS deduction FROM tbl_dv dv LEFT OUTER JOIN tbl_payroll pr on dv.dv_id = pr.dv_id LEFT OUTER JOIN tbl_payroll tpr on tpr.dv_id = dv.dv_id WHERE dv.respo='".mysql_real_escape_string($data[0])."' && year(dv.date_added)=$year && month(dv.date_added)=$month ";

$run_viewrecord = mysql_query($viewrecord) or die(mysql_error());

{
etc....
它应该像这个没有撇号的示例:

http://xxxxx/xxxxx/reports/view_reports.php?respo=BIPC%2B2014-02-04+10%3A53%3A04

您需要对传递的$\u GET值使用urlencode/decode,这样它就不会截断撇号后面的信息。那会解决你的问题

您可以对上面发布的代码进行解码,如下所示:
$respo=urldecode($_GET['respo'])

您准备此语句的代码是:
$variable=urlencode($row['somethinghere'])


现在,如果它包含撇号,它仍然可以发送整个数据字符串。

从哪里获取数据的$data?您可以发布该变量的var_转储吗?删除
中的
AS
AS declutation
。另外,您可能希望将
&
更改为
,并且
看起来不像
$data
正在使用g设置在任何位置?…错误与RESPO无关。它与
$data[1]
有关。错误意味着
$data
没有2个元素,因此没有
$data[1]
http://xxxxx/xxxxxx/reports/view_reports.php?respo=PROV
http://xxxxx/xxxxx/reports/view_reports.php?respo=BIPC%2B2014-02-04+10%3A53%3A04