this is a piece of a module detection script for a dynamic content engine i am making.
If a module is in the folder, it adds it to the database when the admin tool is called.
It checks to see if the module is already in the database, and if it is in the folder, but not in the database, then it adds it to the database
the problem is where it says if(!mysql_num_rows($check)) { It functions perfectly fine, but MySQL outputs an error when it does not find anythign in the database and says that the result from mysql_num_rows() is invalid
thanks a lot if you can help XD
<?php
//search for uninstalled modules
$curdir = opendir("modules");
include($connect_src);
while($dir = readdir($curdir)) {
if(strlen($dir) >= 4){
$dirstr = $dir[0].$dir[1].$dir[2].$dir[3];
if(is_dir("modules/".$dir) && ($dirstr == "dce_") && is_file("modules/".$dir."/info.php")) {
$query = "SELECT dir_name FROM modules WHERE dir_name = '".$dir."'";
$check = mysql_query($query);
if(!mysql_num_rows($check)) {
include("modules/".$dir."/info.php");
$query = "INSERT INTO modules VALUES ('NULL','".$name."','".$dir."','".$root."modules/".$dir."','".$version."','".$vers_output."','".$creator."',NOW())";
register_module($connect_src,$query);
}
}
}
}
?>
You should use:
if ($check = mysql_query($query))
to check if you got something!
Hth
Phetu