I've got a very simple script that records IP address of every page view. Here is the script:
$ip = $_SERVER['REMOTE_ADDR'];
$query = "INSERT INTO tracking VALUES ('', '1', '$ip')";
echo $query;
echo ("<hr>");
if (mysql_query($query)) {
echo ("INSERT OK");
} else {
echo ("INSERT failed");
}
FYI: the 1st value is "auto_increment" in the DB, therefore blank ('') in the query string, and the 2nd value "1" is just for the page number 1, as this script will be on other pages, with different numbers.
Now, when I go to this page, it outputs the query, and hr, and then "INSERT failed" and sure enough, no record gets added to the DB.
The strangest thing is, is that when I copy the query that the page shows, and paste it into mysqlPHPadmin's "SQL" section and run it, it executes fine, and a record gets added to the DB, however the page is unable to do that.
Any ideas?
PS: the connection (which I didn't paste in here) is fine, that's definitely not the problem.