Ok.. so it didn't matter about the brackets, but I did some more testing..
I think the problem lies within what I do after that loop. What I am trying to achieve is something like this:
$sql = "SELECT * FROM tbl where (to_days(now()) - to_days(Dated) >= 2) and Status = 'Expired'";
$connection = mysql_connect("localhost", "user", "pass")
or die ("Couldn't connect to server.");
$db = mysql_select_db("db")
or die ("Database could not be selected. Please inform the Administrator.");
$sql_result = mysql_query($sql)
or die("Selection of expired posts could not be obtained. Please inform the Administrator.");
if (mysql_num_rows ($sql_result) == 0) {
echo "No expired records worth moving at this time.";
exit;
} else {
while ($row = mysql_fetch_array($sql_result)) {
$id = $row["ID"];
$name = $row["Name"];
$email = $row["Email"];
$sql2 = "INSERT INTO tbl2 VALUES ('$id', '$name', '$email')";
$connection = mysql_connect("localhost", "user", "pass")
or die ("Couldn't connect to server.");
$db = mysql_select_db("db")
or die ("Database could not be selected. Please inform the Administrator.");
$sql_result = mysql_query($sql2)
or die ("Items could not be inserted. Please inform the Administrator.);
// or die("Addition could not be made to the past. Please inform the Administrator.");
}
}
I was able to remove the second half and just echo the looped items just fine, but the problem lies where I try to insert the looped values into another table.
So you see, I want to suck out the data that's 2 days or older and insert the values into another table.
Where am I going wrong with this?