Fabis94 Posted July 9, 2009 Share Posted July 9, 2009 I have this function: function pruneTrue($regdate1, $i, $auto_prune_date) { //Must be YYYY-MM-DD $query = "SELECT * FROM hosted_forums"; $result = mysql_query($query); $fname=mysql_result($result,$i,"fname"); //Forum Name $table = $fname . "_isawaiting_activation"; echo $table . ' '; $check = mysql_is_table($table); if ($check != TRUE) { echo ' FALSE LOL '; return false; } else { $query22 = mysql_query("SELECT * FROM " . $table); print_r($query22); $autoprune = $auto_prune_date * 86400; //1 unix day = 86400 $todayd = date("Y-m-d"); $today = strtotime($todayd); $regdate = strtotime($regdate1); $expire = $regdate + $autoprune; if ($today > $expire) { return true; } else { return false; } } } This is the mysql_is_table(): function mysql_is_table($tbl) { $tables = array(); $q = @mysql_query("SHOW TABLES"); while ($r = @mysql_fetch_array($q)) { $tables[] = $r[0]; } @mysql_free_result($q); if (in_array($tbl, $tables)) { return TRUE; } else { return FALSE; } } Anyways the first function results in 1 and causes other weird stuff in my script. What is wrong with it? Quote Link to comment Share on other sites More sharing options...
btherl Posted July 9, 2009 Share Posted July 9, 2009 The first thing you need to do is check return values for mysql_query(). And please remove all "@" signs from your code. At the debugging stage you want to know all of the errors. For example: function mysql_is_table($tbl) { $tables = array(); $q = mysql_query("SHOW TABLES") or die("SHOW TABLES failed: " . mysql_error()); while ($r = mysql_fetch_array($q)) { $tables[] = $r[0]; } # no @ - if there's an error here we want to know! mysql_free_result($q); # Again, we want to see the error if something is wrong. if (in_array($tbl, $tables)) { return TRUE; } else { return FALSE; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.