StevenY Posted August 8, 2008 Share Posted August 8, 2008 Ok, here it is, I know it has to do with my Define Array, but it works in the insert script.. Now the Connection is in another file and it connects just fine.. I am Getting this error "failed because Unknown column '$TODAY' in 'where clause' " I want it to collect the date then pull the records based on that date, would be nice if it could actually do the day prior <?php $TODAY = date('Y-m-d'); $sql = 'SELECT `DATE` , COUNT( IP ), `DOC` FROM `track_visit` WHERE `DATE` = `$TODAY` GROUP BY `DOC`'; // display stats $result = mysql_query($sql) or die($result.'failed because '.mysql_error()); $numres = mysql_num_rows($result); $cur = 1; $i = 1; echo " <table border=1>"; echo " <tr>"; echo " <td WIDTH=150>DATE</td>"; echo " <td WIDTH=150>HITS</td>"; echo " <td WIDTH=150>PAGE</td>"; echo " </tr>"; while ($numres >= $cur) { $row = mysql_fetch_array($result); echo " <tr>"; echo " <td>$row[0]</td>"; echo " <td>$row[1]</td>"; echo " <td>$row[2]</td>"; echo " </tr>"; $cur++; } echo " </table>"; ?> Quote Link to comment Share on other sites More sharing options...
fenway Posted August 9, 2008 Share Posted August 9, 2008 You need single quotes around $TODAY, not backticks. Quote Link to comment Share on other sites More sharing options...
StevenY Posted August 9, 2008 Author Share Posted August 9, 2008 When I use the Single Quote ' like this $sql = 'SELECT `DATE` , COUNT( IP ), `DOC` FROM `track_visit` WHERE `DATE` = '$TODAY' GROUP BY `DOC`'; I get this Error Parse error: parse error, unexpected T_VARIABLE in /home/content/s/a/a/Site Name/html/directoryname/dailyhitlog.php on line 4 I think I forgot to mention The server is setup with PHP 4.1 and MySQL 4.1 or 4.3 as well. Steven Quote Link to comment Share on other sites More sharing options...
fenway Posted August 9, 2008 Share Posted August 9, 2008 That's because you need to change your outer quotes to doubles -- otherwise your variable won't get interpolated. Quote Link to comment Share on other sites More sharing options...
StevenY Posted August 9, 2008 Author Share Posted August 9, 2008 That explains it, Now I feel realy stupid for staring at that for a couple of days before asking as I knew a stupid question.. Steven Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.