Php 选择数组不显示结果

Php 选择数组不显示结果,php,arrays,select,Php,Arrays,Select,我正在编写一个CRON作业,它将每天执行。首先,它将从MySql表中识别“FAPforSale_repost35”字段中的日期,如果日期是今天的日期,它将执行命令删除目录中的照片图像,删除目录,最后从数据库中删除记录 我正在进行第一步,即构建与日期匹配的记录数组。当我运行代码时,没有错误,但即使测试表中的记录设置为今天,我也没有得到结果。下面是选择 <?php define( "DIR", "../zabp_employee_benefits_processor_filesSm/",

我正在编写一个CRON作业,它将每天执行。首先,它将从MySql表中识别“FAPforSale_repost35”字段中的日期,如果日期是今天的日期,它将执行命令删除目录中的照片图像,删除目录,最后从数据库中删除记录

我正在进行第一步,即构建与日期匹配的记录数组。当我运行代码时,没有错误,但即使测试表中的记录设置为今天,我也没有得到结果。下面是选择

<?php

 define( "DIR", "../zabp_employee_benefits_processor_filesSm/", true );

 require( '../zipconfig.php' );
 require( DIR . 'lib/db.class.php' );
 require_once( $_SERVER['DOCUMENT_ROOT'] . '/_ZABP_merchants/configRecognition.php' );
 require_once( $_SERVER['DOCUMENT_ROOT'] . '/_ZABP_merchants/libRecognition/MailClass.inc' );



$todayRepost35 = date("Y-m-d");
echo $todayRepost35;



function repostEndSelect()

      {

        global $db;

    $this->db = $db;


     $data = $this->db->searchQuery( "SELECT `FAPforSale_IDnumber`,  `FAPforSale_image1`,  `FAPforSale_image2`,  `FAPforSale_image3`,  `FAPforSale_repost35`  FROM  `FAP_forSaleTest` Where `FAPforSale_repost35` = '$todayRepost35' ");


        $this->FAPforSale_IDnumber = $data[0]['FAPforSale_IDnumber'];
        $this->FAPforSale_image1 = $data[0]['FAPforSale_image1'];
        $this->FAPforSale_image2 = $data[0]['FAPforSale_image2'];
        $this->FAPforSale_image3 = $data[0]['FAPforSale_image3'];
        $this->FAPforSale_repost35 = $data[0]['FAPforSale_repost35'];

        echo $this->FAPforSale_IDnumber;
        echo $this->FAPforSale_image1;
        echo $this->FAPforSale_image2;
        echo $this->FAPforSale_image3;
        echo $this->FAPforSale_repost35;

    } // ends function...

echo( ' Finished...' );

?>

$todayRepost35
不在功能范围内。您必须将其限定在函数的范围内,或者将其作为参数传递(最好是后者):

或:

此外,在函数中使用
$this
也不起作用。如果函数是类的一部分,而您(出于某种原因)没有包含类定义,则忽略此项

function repostEndSelect() {
    global $db;
    global $todayRepost35;
    // ...
}
function repostEndSelect($todayRepost35) {
    global $db;
    // ...
}
// ...
$test = repostEndSelect($todayRepost35);