Jump to content

[SOLVED] Help Please - I know I am making stupid mistake...


StevenY

Recommended Posts

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>";

?>

 

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.