Firstly... in this line of code:
while($data = mysql_fetch_assoc($mysqlFiles));
^ end of statement, stops the process.
- Notice the semi-colon at the end there?
Believe it or not, that is considered as valid syntax (and won't throw an error because of it), BUT... is also ending your statement and will not process { $imageNames[] = $data; }
.
Whether the query is successful or not, it will still STOP right there.
Remove it
while($data = mysql_fetch_assoc($mysqlFiles))
Reference on semi-colon:
"As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement. The closing tag of a block of PHP code automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a PHP block. The closing tag for the block will include the immediately trailing newline if one is present."
If you want to catch potential errors, use mysql_error()
against your query
Something else I noticed is that you're not "querying" with mysql_query()
.
so your code will never result in a successful query along with what's already been said.
Example from the manual:
$query = sprintf("SELECT firstname, lastname, address, age FROM friends
WHERE firstname='%s' AND lastname='%s'",
mysql_real_escape_string($firstname),
mysql_real_escape_string($lastname));
// Perform Query
$result = mysql_query($query);
Example from http://php.net/manual/en/function.mysql-fetch-assoc.php
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
If the following were coded as such and with the semi-colon, it would not process anything inside {...}
:
while ($row = mysql_fetch_assoc($result)); {
// ^ semi-colon terminator similar to yours
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}