Hello
I want to set a variable using date() to use in a later query but it keeps falling over and I get a sql error message!
the code I have got is;
//$today = date('Y-m-d'); // this is the actual code I plan to use but it is commented out because I am testing the code using the line below
$today = date('2004-12-07'); // this line is for testing purposes only
// PART 1 - Send "we are open" email
$body1 = "Hello,
Please note that we are open.
We kindly request you log on.
regards
'$Name'
";
$query = "SELECT Ref FROM tblDate WHERE OpenEarly = " . $today;
$result = mysql_query($query)
or die(mysql_error());
while ($row = mysql_fetch_array($result));
$Ref[] = $row["Ref"];
foreach ($Ref as $value)
{
$sql = "SELECT Name FROM tblConces WHERE ConcesId == '$Ref'";
$result1 = mysql_query($sql)
or die(mysql_error());
$row1 = mysql_fetch_array($result1);
$Name = $row1["Name"];
$sql = "SELECT Email FROM tblUser WHERE Level >= 3 AND Ref == '$Ref'";
$result2 = mysql_query($sql)
or die(mysql_error());
while($row2 = mysql_fetch_array($result2))
$Email[] = $row2["Email"];
foreach($Email as $value)
{
mail ("$Email", "subject", "$body1");
}
}
but I keep getting the error message You have an error in your SQL syntax near '== 2004-12-07' at line 1 which is the line $query = "SELECT Ref FROM tblDate WHERE OpenEarly = " . $today;
Note - I get the same error message if I use the actual date() code $today = date('Y-m-d'); and change the date on the database when I try to make the code work
any ideas where I am going wrong?