0

我承认我见过与我的问题类似的其他问题。但是,我仍然不知道错误意味着什么,更不用说如何修复它了。

当我通过浏览器执行 PHP 脚本时,它工作正常。不返回任何错误。但是,当它通过 wget(或 curl)作为 cron 作业运行时,我的事件处理程序报告:“未定义的偏移量:84”

function MLSEscapeValues($pieces){
   // escape all of the values in the array

   global $ExtraDebugInfo;  // additional argument for error handler

   $PieceCount = count($pieces);

    for($k=0;$k <= ($PieceCount-1);$k++){

        $ExtraDebugInfo .= "PieceCount = $PieceCount and k = $k and value = ".$pieces[$k]."<br>";
        $pieces[$k] = mysql_real_escape_string($pieces[$k]);

    }

    return $pieces;
}

我已经验证了索引数组在每一行中都包含数据,但并非所有字段都有值(预期)。

感谢您的帮助。

编辑:

$piece 数组的样本数据

Pieces[0] = 2.57
Pieces[1] = 21-30 Years
Pieces[2] = Traditional
Pieces[3] = 208  
Pieces[4] = 
Pieces[5] = 0
Pieces[6] = Slab
Pieces[7] = 3
Pieces[8] = 0
Pieces[9] = 4
Pieces[10] = 
Pieces[11] = 1
Pieces[12] = City
Pieces[13] = Frame,Wood Siding
Pieces[14] = Central Electric,Heat Pump
Pieces[15] = County
Pieces[16] = Breakfast Room,Formal Dining
Pieces[17] = Directions
Pieces[18] = 2013-01-05T14:59:58.607
Pieces[19] = Ceiling Fan(s),Dishwasher,Rng/Oven- Electric,Smoke Detector
Pieces[20] = 
Pieces[21] = Sat Dish Allowed
Pieces[22] = 1
Pieces[23] = 1
Pieces[24] = Great Room
Pieces[25] = Earth Contact,Ranch
Pieces[26] = 1
Pieces[27] = 2
Pieces[28] = Attached,Front Entry
Pieces[29] = Central Electric,Heat Pump
Pieces[30] = 0
Pieces[31] = 
Pieces[32] = 
Pieces[33] = No
Pieces[34] = Walk-In Closet
Pieces[35] = agentid
Pieces[36] = Name
Pieces[37] = 800-555-1212
Pieces[38] = 
Pieces[39] = id
Pieces[40] = Name
Pieces[41] = 800-555-1211
Pieces[42] = 
Pieces[43] = Excl Right To Sell
Pieces[44] = 
Pieces[45] = Acreage,Level,Treed
Pieces[46] = 
Pieces[47] = 23828274
Pieces[48] = 1794131
Pieces[49] = 
Pieces[50] = Enclosed Porch,Main Floor BR,Main Floor Master
Pieces[51] = 11
Pieces[52] = 2012-08-20T14:51:09.967
Pieces[53] = 159900
Pieces[54] = 
Pieces[55] = 
Pieces[56] = Composition
Pieces[57] = 
Pieces[58] = 
Pieces[59] = School Dist
Pieces[60] = Elementary
Pieces[61] = Middle
Pieces[62] = High School
Pieces[63] = 
Pieces[64] = 2710
Pieces[65] = State
Pieces[66] = Temporarily Off Market
Pieces[67] = FirstName
Pieces[68] = E
Pieces[69] = 7000
Pieces[70] = Circle
Pieces[71] = Oak
Pieces[72] = Single Family
Pieces[73] = 2109
Pieces[74] = Private
Pieces[75] = Main Level,Laundry Room
Pieces[76] = 
Pieces[77] = 
Pieces[78] = 
Pieces[79] = 
Pieces[80] = City/Public
Pieces[81] = Cash,Conventional,FHA,VA
Pieces[82] = 1986
Pieces[83] = 99999
Pieces[84] = 
Pieces[85] = 
4

1 回答 1

0

没有足够的信息,但您$pieces来自(或者您正在构建)*SQL 查询,对吗?可能是语法错误,并且您从哪个数据库函数返回的值不是您期望的数组。

第一站是echo任何错误,看看是否是这种情况。

mysqli
PDO
mysql <--不应该使用这个批次

于 2013-03-14T16:44:04.767 回答