A small puzzling Error message about 'user'
Posted: Tue Jun 11, 2024 8:52 pm
I created my website some versions ago of WWB, and with my advanced years have trouble remembering what I did - and have done since.
I only this evening noticed a tiny message at the top of my Home page donjohnson24.co.uk which states:
Notice: Undefined variable: user in /home/zo4j7dtqd36t/public_html/index.php on line 35
It appears to be associated with an insert that detects if the site is being accessed from my computer, and if so - or is a revisit by someone else - does NOT update the Visitor counter.
I changed the Ident Name in the Counter Extension from what I originally set as DON, to Don3 - my current login name, but the error persists.
I'm hampered by the fact that as the lines are not numbered when I view the html, as I cannot find a match between 'user' and line 35 ??
This is a trivial problem, but I know that when I was more 'with it' I enjoyed solving queries like this, so I hope someone younger might take pity on my plight and help me remove my error message.
The first part of the html is here: - spaced just as I see it when I view it using Edit in WinSCP
<?php
$revisit = "No";
//check if first visit
if(isset($_COOKIE["first"]))
{
$revisit = "Yes" ;
$play = " " ;
}
else
{
$cookie_name = "first";
$cookie_value = "XX";
setcookie($cookie_name, $cookie_value);
$play = "autoplay" ;
}
//check if MY computer
$cookie_name = "DONCHECK";
if(isset($_COOKIE[$cookie_name]))
{
$user = $_COOKIE[$cookie_name];
}
// get the visit count, and update if first visit and NOT on my computer
$file = fopen("Counter.txt", 'r');
$data = fread($file, filesize("Counter.txt"));
fclose($file);
if ($data !== false)
{
$hits = intval($data);
if ($user != "Don3" && $revisit != "Yes")
{
$hits++;
$file = fopen("Counter.txt", 'w');
flock($file, LOCK_EX);
fwrite($file, $hits);
flock($file, LOCK_UN);
fclose($file);
}
}
?>
<!doctype html>
<html>
<head>
<title>Don Johnson's Personal Website</title>
I only this evening noticed a tiny message at the top of my Home page donjohnson24.co.uk which states:
Notice: Undefined variable: user in /home/zo4j7dtqd36t/public_html/index.php on line 35
It appears to be associated with an insert that detects if the site is being accessed from my computer, and if so - or is a revisit by someone else - does NOT update the Visitor counter.
I changed the Ident Name in the Counter Extension from what I originally set as DON, to Don3 - my current login name, but the error persists.
I'm hampered by the fact that as the lines are not numbered when I view the html, as I cannot find a match between 'user' and line 35 ??
This is a trivial problem, but I know that when I was more 'with it' I enjoyed solving queries like this, so I hope someone younger might take pity on my plight and help me remove my error message.
The first part of the html is here: - spaced just as I see it when I view it using Edit in WinSCP
<?php
$revisit = "No";
//check if first visit
if(isset($_COOKIE["first"]))
{
$revisit = "Yes" ;
$play = " " ;
}
else
{
$cookie_name = "first";
$cookie_value = "XX";
setcookie($cookie_name, $cookie_value);
$play = "autoplay" ;
}
//check if MY computer
$cookie_name = "DONCHECK";
if(isset($_COOKIE[$cookie_name]))
{
$user = $_COOKIE[$cookie_name];
}
// get the visit count, and update if first visit and NOT on my computer
$file = fopen("Counter.txt", 'r');
$data = fread($file, filesize("Counter.txt"));
fclose($file);
if ($data !== false)
{
$hits = intval($data);
if ($user != "Don3" && $revisit != "Yes")
{
$hits++;
$file = fopen("Counter.txt", 'w');
flock($file, LOCK_EX);
fwrite($file, $hits);
flock($file, LOCK_UN);
fclose($file);
}
}
?>
<!doctype html>
<html>
<head>
<title>Don Johnson's Personal Website</title>