troubleshooting Question

MySQL, Searching for a nonexistant record

Avatar of HitByASquirrel
HitByASquirrel asked on
11 Comments1 Solution233 ViewsLast Modified:
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

     //search for uninstalled modules
     $curdir = opendir("modules");
     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)) {
                         $query = "INSERT INTO modules VALUES ('NULL','".$name."','".$dir."','".$root."modules/".$dir."','".$version."','".$vers_output."','".$creator."',NOW())";

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros