Warning: mysqli_query() expects parameter 1 to be mysqli, string given in ... on line 5

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in ... on line 6

<?php
require_once("../account/connect_to_mysql.php");
// This block deletes all accounts that do not activate after 2 days at Midnight
$sql = "SELECT id FROM members WHERE signupdate<=CURRENT_DATE - INTERVAL 2 DAY AND emailactivated='0'";
$query = mysqli_query(connect_to_mysql, $sql);
$numrows = mysqli_num_rows($query);
if ($numrows > 0) {
		while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
			$id = $row['id'];
			$id = "../memberFiles/$id";
			if (is_dir($id)) {
				rmdir($id);
			}
			$sql = "DELETE FROM members WHERE id='id' AND emailactivated='0' LIMIT 1";
			$query = mysqli_query($db_conx, $sql);
		}
}
?>

    Is "connect_to_mysql" supposed to be a variable?

      your right, forgot to fix that, however I'm still getting the same error

      <?php
      require_once("../account/connect_to_mysql.php");
      // This block deletes all accounts that do not activate after 2 days at Midnight
      $sql = "SELECT id FROM members WHERE signupdate<=CURRENT_DATE - INTERVAL 2 DAY AND emailactivated='0'";
      $query = mysqli_query($db_nonx, $sql);
      $numrows = mysqli_num_rows($query);
      if ($numrows > 0) {
      		while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
      			$id = $row['id'];
      			$id = "../memberFiles/$id";
      			if (is_dir($id)) {
      				rmdir($id);
      			}
      			$sql = "DELETE FROM members WHERE id='id' AND emailactivated='0' LIMIT 1";
      			$query = mysqli_query($db_conx, $sql);
      		}
      }
      ?>

        All I want to do is when I run this file it will delete the member and member info including the folder (memberFiles) set to the users ID.

          Have you used [man]mysqli_error[/man] after the offending line to find out why the query failed?

            Write a Reply...