My error is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND (tblforecast.Issued like '%01-07%' ))order by tblforecast.Issued DESC' at line 2
My code is:
$news = "SELECT tblforecast.Fore_ID, tblforecast.Issued,
tblforecast.Synopsis,tblforecast.Forecaster, tblusers.FirstName,
tblusers.LastName FROM tblforecast
INNER JOIN tblusers ON tblusers.UserNumber = tblforecast.forecaster
WHERE ((tblforecast.Valid =$type)
AND (tblforecast.Issued like '%$filter%' ))
order by tblforecast.Issued DESC";
If I only have one condition in my WHERE statement, it works.
$type is either 24 or 12. $filter is "mm-dd" in numeric form.
after this is executed, it will proceed to the displaying of the news which is:
$loadnews = mysql_query($news);
if (!($loadnews))
echo mysql_error();
while($waiting = mysql_fetch_array($loadnews))
{
$NiD = $waiting['Fore_ID'];
$thedate = $waiting['Issued'];
$synop = $waiting['Synopsis'];
$forecaster = $waiting['FirstName']." ".$waiting['LastName'];
$dDate = strtotime($thedate);
$newDate = date('F j, Y',$dDate);
echo "<div class='well well-large'>
<p><b>$newDate</b>
<br><small><i>$forecaster</i></small>
<br>$synop</p>
<br><small><a href='pdetails.php?NiD=$NiD'>Read More</a></small></p>
</div>";
}
In response to the requests for the content of $news
, this is what it holds after the assignment statement:
SELECT tblforecast.Fore_ID, tblforecast.Issued, tblforecast.Synopsis,tblforecast.Forecaster, tblusers.FirstName, tblusers.LastName FROM tblforecast INNER JOIN tblusers ON tblusers.UserNumber = tblforecast.forecaster WHERE ((tblforecast.Valid =) AND (tblforecast.Issued like '%01-07%' ))order by tblforecast.Issued DESC