Why is my MySQL being written to twice with only one code line?

Glenn

Member
I have in my code,
mysql_query("INSERT INTO 80sMusicLibraryUserNumPageVisits (userNum, date, page) VALUES ('$userNum', '$dateToday', '$newUrl')");

It will write a record of:
1 2014-02-16 1980
wich would be correct. I'm user 1 because I was the first on the site. Date and page is also correct. But, it will follow with a record of:
1 2014-02-16 missing.html

Why is it doing this??
It does it every time. I even went to the site on my phone and it did the same thing.

This is the only query to this table. It is not in a loop. It is not in a function.

Where did the value "missing.html" come from, and how could the $newUrl variable be set to that? I have no page called that.
 

chrishirst

Well-Known Member
Staff member
Probably because you do not catch errors and it is running on a HTTP: 404 error as well.
 

chrishirst

Well-Known Member
Staff member
"missing.html" is a common name used by some sitebuilder and content management systems for the "Page not found" URL.

How do you fix it???

Absolutely no idea I'm just a programmer not a clairvoyant.
 

Glenn

Member
"missing.html" is a common name used by some sitebuilder and content management systems for the "Page not found" URL.

How do you fix it???

Absolutely no idea I'm just a programmer not a clairvoyant.

I'm the "sitebuilder". I built it all by my written code.
 

Glenn

Member
I just now changed the code to:

if ($userNum != 1) {
mysql_query("INSERT INTO 80sMusicLibraryUserNumPageVisits (userNum, time, date, page) VALUES ('$userNum', '$time', '$dateToday', '$newUrl')");
}

and it created a new $userNum and recorded a page visit by that new userNum to each page I went to.
 

chrishirst

Well-Known Member
Staff member
The SQL code is of ABSOLUTELY no use at all to even GUESS at what the PHP code is doing, or NOT as the case maybe.
 
Top