I have an older script which I’m slightly refactoring, though now its showing an error I can’t quite figure why.
Notice : Undefined property: stdClass::$DATA in /home/… on line 95
Can anybody see what I’m doing wrong?
$stmt = $mysqli->query("
SELECT CONCAT(event_id,venue_id) AS link
, DATE_FORMAT(date, '%M %D %Y') AS drlist
, date
, about
, photo
FROM gallery_details
ORDER BY gallery_details.date DESC");
$row_cnt = $stmt->num_rows;
$set = array();
while ($record = mysqli_fetch_object($stmt)) {
$record->e_link = str_replace(" ","-",($record->link)); // Line 95
$set[$record->DATA][] = $record;
}
...
}
Your query does not have a column called DATA so $record->DATA obviously does not exist. What is $record->DATA supposed to be? date maybe? drlist perhaps?
I’m not really sure
As mentioned, this is an older script and from what I can remember I needed to add this because of some CONCAT - though I could be wrong.
Would you say it’s safe to remove? (If its doing nothing)
I did think it was conected to: foreach ($set as $DATA => $records) {
And thanks @ahundiak
Yes this does seem strange, not sure.
If you’re only using $set in this one place, i don’t see a need for the reference. Or even the multidimensional array. Were you pulling data from multiple queries for some reason?
Well, i’m sure certain individuals will be along momentarily to suggest you scrap the entire thing and ‘figure out your real problem’, but for a simple refactor…
$set[$record->DATA][] = $record;
=> $set[] = $record;
, and