I have a problem with getting MySQL column into php array variable , for further foreach() cycling.
Here is my code:
$files=array();
$filesFetch = "SELECT FileName FROM articledata";
$rs=mysql_query($filesFetch);
while($rd=mysql_fetch_object($rs))
{
$files[]=$rd->files;
}
if (!$files) {
die('getting filenames failed');
}
foreach ($files as $key => $id)
{ //... do the stuff }
I am not getting stopped at the die condition, but my error says:
Notice: Undefined property: stdClass::$files
I assume there is problem with formatting, because this error notice repeats :"rowCountTimes"
Also this error appears for the line.
$files[]=$rd->files;
mysql_*functions in new code. They were removed from PHP 7.0.0 in 2015. Instead, use prepared statements via PDO or MySQLi. See Why shouldn't I use mysql_* functions in PHP? for more information.