I am just trying to save the current page that the user is viewing in the database. When the page loads, I insert $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING'] $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING'] to your database, but only the page appears (for example, index.php? ), Without a query string (I checked that there is a query string in the URL).
I tried $_SERVER['PHP_SELF'] with the same results.
EDIT ADD: Here is the $ _SERVER dump:
Array ( . . . [REQUEST_METHOD] => GET [QUERY_STRING] => view=scores&yr=2010&wk=1 [REQUEST_URI] => /index.php?view=scores&yr=2010&wk=1 . . . )
So, the query string is present in the array, even as part of REQUEST_URI. So my request ...
mysql_query("insert into clickstream (user_id, page) values (" . $_SESSION['user_id'] . ", '" . mysql_real_escape_string($_SERVER['REQUEST_URI']) . mysql_real_escape_string($_SERVER['QUERY_STRING']) . "');") or die('mysql error: ' . mysql_error());
... should insert a query string twice, not time!
Thoughts?
ADDED THOUGHT: Is it possible that MySQL DB removes everything from input outside ? ? The field is varchar.
UPDATE W / PARTIAL SOLUTION: Changing SQL input only to $_SERVER['QUERY_STRING'] (without REQUEST_URI) successfully enters the query string. So this makes me believe that either PHP or MySQL extracted everything from the input line after ? . Thus, the input parameters were correct; the result just sat down.
Does anyone know why this could be so?
source share