I have a really simple query that I cannot get to work for love nor money!
the whole code is
$today = date('Y-m-d');
//formatted to match the date in the database
$query = "SELECT CRef FROM tblDate WHERE OpenEarly = $today";
$result = mysql_query($query)
or die(mysql_error());
while ($row = mysql_fetch_array($result));
$CRef[] = $row["CRef"];
foreach ($CRef as $value)
{
$body1 = "Hello, blah blah blah
regards
'$CoName'
";
$query = "SELECT CoName FROM tblConces WHERE ConcesId = '$ConcesRef'";
$result1 = mysql_query($query)
or die(mysql_error());
$row1 = mysql_fetch_array($result1);
$CoName = $row1["CoName"];
$query = "SELECT CEmail FROM tblUser WHERE AuthorityLevel >= 3 AND ConcesRef = '$ConcesRef'";
$result2 = mysql_query($query)
or die(mysql_error());
while($row2 = mysql_fetch_array($result2))
$CEmail[] = $row2["CEmail"];
foreach ($CEmail as $value)
{
mail ("$CEmail", "subject", "$body1");
}
I have tested quite a few of the variables and the start of the problem is at $today
I have echo'd out $today and it outputs what I would expect in the correct format, but when I try to match it to the date in the database I get nothing.
I have done print_r($CRef) and get Array ( [0] => ) but I know there is one record in the database that matches the criteria. So from here on in none of the code will work........
Is there something in the way dates work that I am missing, something that is causing this problem?
I am also getting the error message Invalid argument supplied for foreach() on the second foreach
foreach ($CEmail as $value)
{
mail ("$CEmail", "subject", "$body1");
}
again any ideas? can't you have a foreach within a foreach?
thanks in advance