Counter help plse :-(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
r3m8o1
Forum Newbie
Posts: 2
Joined: Fri Jul 08, 2005 5:44 pm

Counter help plse :-(

Post by r3m8o1 »

Hello people,

I'm building a site with php, javascript and a mysql database. This page consists out of a titleFrame (with a counter), a loginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a better way to do it I'm also listening :-)

p.s. sorry for my bad englisho). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a better way to do it I'm also listening :-)

p.s. sorry for my bad englishblue]$visitor->visitorID = $row["visitorID"];
$visitor->visitorIP = $row["visitorIP"];
$visitor->visitorVisitDate = $row["visitorVisitDate"];
$visitor->visitorVisitTime = $row["visitorVisitTime"];
$visitor->visitorBrowser = $rowї&quote;visitorBrowser&quote;];
$visitor->visitorOS = $rowї&quote;visitorOS&quote;];
$visitor->visitorOSLanguage = $rowї&quote;visitorOSLanguage&quote;];
$visitor->userID = 0;
}

Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a better way to do it I'm also listening :-)

p.s. sorry for my bad englisha mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a better way to do it I'm also listening :-)(or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. Wheisitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echpage consists out of a titleFrame (with a counter), a loginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't i'm building a site with php, javascript and a mysql database. This page consists out of a titleFrame (with a counter), a loginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the sessioginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldre for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

[color=green:68), a loginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database asloginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannotse to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a better way to do it I'm also listening :-)

p.s. sorry for my bad englishks like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime&eFrame (with a counter), a loginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table [color=blue]if (!IsSet($_SESSION["visitor"]))[/color]. It works like this:

Code: Select all

mysql_query(&quote;INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strangea mysql database. This page consists out of a titleFrame (with a counter), a loginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the str. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a better way to do it I'm also listening :- this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a ote;REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"base (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new sta and a mysql database. This page consists out of a titleFrame (with a counter), a loginFrame, a menuFrame and a mainFrame. Only the titleFrame and mainFrame are important here for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I search everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists)for this to work.

Now everytime someone visits my homepage this persons stats will be saved into the database (or that's what I want my page to do). What I do is the following: I connect to my database to add visitor stats to a certain table if (!IsSet($_SESSION["visitor"])). It works like this:

Code: Select all

mysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to thi. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they shoumysql_query("INSERT INTO visitor (visitorIP, blahblah) VALUES ('". $_SERVER["REMOTE_ADDR"]. "', 'blahblah')") or die(mysql_errno(). ": ". mysql_error());
Then I do the following to get the current visitorID (or number or what you want to call it):

Code: Select all

$dbsQuery = "SELECT * FROM visitor ORDER BY visitorID DESC LIMIT 1";
$result = mysql_query($dbsQuery) or die (mysql_error());
Then:

Code: Select all

if (!$row = mysql_fetch_array($result)) {
   blahblah;
} else {
   $visitor = new visitorClass; //OFCOURSE DEFINED AT THE START OF MY PAGE

   [color=blue]$visitor->visitorID			= $row["visitorID"];
   $visitor->visitorIP			= $row["visitorIP"];
   $visitor->visitorVisitDate	= $row["visitorVisitDate"];
   $visitor->visitorVisitTime	= $row["visitorVisitTime"];
   $visitor->visitorBrowser	= $row["visitorBrowser"];
   $visitor->visitorOS			= $row["visitorOS"];
   $visitor->visitorOSLanguage	= $row["visitorOSLanguage"];
   $visitor->userID			= 0;
}
Then I want to save the session:

Code: Select all

$_SESSION["visitor"] = $visitor;
If I want to show in my counter in my titleFrame what my current visitorNumber is I'll just have to echo $_SESSION["visitorID"];...
Now the strange thing is that when I visit my page for the first time the stats are entered into my database as they should be added (checked with MySQL Query Browser). But when I want to display those stats into my mainFrame (thus asking for $_SESSION["visitor"]) it doesn't display anything. When I hit F5 however the visitorID increases with 1, new stats are saved to the database and then $_SESSION["visitorID"] suddenly DOES exist also for the mainFrame. When I hit F5 again visitorID doesn't increase (and it shouldn't increase if the session already exists).

Is there any way to solve this? I searched the internet and I cannot find anything related to this topic. If there's a better way to do it I'm also listening :-)

p.s. sorry for my bad english
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

well im not sure i see any problem with your current code but you might be making a simple mysql counter a little too complicated.

try somthing like this

Code: Select all

session_start();

if (!isset($_SESSION['visitor']))
{
  //insert info into sql db
  $_SESSION['visitor'] = 'set';
}

//sql to display the counter
you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicateddont need any classes or anything just two sql querys and a session, dont make somthing simple complicatede4044c7bad]
session_start();

if (!isset($_SESSION['visitor']))
{
//insert info into sql db
$_SESSION['visitor'] = 'set';
}

//sql to display the counter


you really dont need any classes or anything just two sql querys and a session, dont


you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicatedon, dont make somthing simple complicatedimple mysql counter a little too complicated.

try somthing like this

Code: Select all

session_start();

if (!isset($_SESSIONї'visitor']))
{
  //insert info into sql db
  $_SESSION['visitor'] = 'set';
}

//sql to see any problem with your current code but you might be making a simple mysql counter a little too complicated.

try somthing like this

Code: Select all

session_start();

if (!isset($_SESSION['visitor']))
{
  //insert info into sql db
  $_SESSION['visitor'] = 'set';
}

//sql to display the counter
you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicatedthing like this

Code: Select all

session_start();

if (!isset($_SESSION['visitor']))
{
  //insert info into sql db
  $_SESSION['visitor'] = 'set';
}

//sql to display the counter
you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicatedsitor']))
{
//insert info into sql db
$_SESSIONї'visitor'] = 'set';
}

//sql to display the counter
[/php:1:etry somthing like this

Code: Select all

session_start();

if (!isset($_SESSIONї'visitor']))
{
  //insert info into sql db
  $_SESSIONї'visitor'] = 'set';
}

//sql to display the counter
you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicatedomthing like this

Code: Select all

session_start();

if (!isset($_SESSION['visitor']))
{
  //insert info into sql db
  $_SESSION['visitor'] = 'set';
}

//sql to display the counter
you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicatedand a session, dont make somthing simple complicatede too complicated.

try somthing like this

Code: Select all

session_start();

if (!isset($_SESSION['visitor']))
{
  //insert info into sql db
  $_SESSION['visitor'] = 'set';
}

//sql to display the counter
you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicatedyou might be making a simple mysql counter a little too complicated.

try somthing like this

Code: Select all

session_start();

if (!isset($_SESSION['visitor']))
{
  //insert info into sql db
  $_SESSION['visitor'] = 'set';
}

//sql to display the counter
you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicated
session_start();

if (!isset($_SESSION['visitor']))
{
//insert info into sql db
$_SESSION['visitor'] = 'set';
}

//sql to display the counter


you really dont need any classes or anything just two sql querys and a session, dont make somthing simple complicated
r3m8o1
Forum Newbie
Posts: 2
Joined: Fri Jul 08, 2005 5:44 pm

Post by r3m8o1 »

I use classes because the information about the visitor is to be used all over the site to make things more speedy. Also I want to store this information in MySQL (that's why it seems so complicated).

The answer you gave me is a solution I've already tried in the past, it doesn't work :-S.

However I tried something news: In the past when someone opened my site the session "visitor" was immediately created bu tnot succesfully. Now I've moved the routines which do that to another frame which is loaded the last by a browser: mainFrame. And now no problemns occur.

Probably it has something to do with the fact that the page isn't fully loaded yet when I created the session.

It's a workaround but it works.

Greetz, and thank you
Post Reply