php - Comparing mysql data with folder files -
i want check if there image record in database not in folder of images, cant seem find way , dont know why, made code:
$result = mysql_query("select imagen galerias", $dbh); $flag = true; mysql_data_seek($result, 0); while($row2 = mysql_fetch_assoc($result)) { $directorio = opendir("../galeria/programas"); while ($archivo = readdir($directorio)) { if($archivo == $row2["imagen"]){ $flag = false; } } if ($flag) { echo "im not in folder ".$row2["imagen"]."<br>"; } } ?> it's load 1 record only..
i think mistakes on $flag, did not reset $flag after each check. if there 1 file equals 1 on db, makes $flag false, rest considered equals since $flag false after that.
and improve using strcmp comparing string rather utilize "==". more binary safe.
php mysql
No comments:
Post a Comment