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

?>

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.