Check if MySQL table exists or not [duplicate]
Updated mysqli version: if ($result = $mysqli->query(“SHOW TABLES LIKE ‘”.$table.”‘”)) { if($result->num_rows == 1) { echo “Table exists”; } } else { echo “Table does not exist”; } Original mysql version: if(mysql_num_rows(mysql_query(“SHOW TABLES LIKE ‘”.$table.”‘”))==1) echo “Table exists”; else echo “Table does not exist”; Referenced from the PHP docs.