Re: save $_GLOBALS to a database field
| From: | Ashley Sheridan | Date: | Thu, 14 Nov 2013 21:58:11 +0000 |
| Subject: | Re: save $_GLOBALS to a database field | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322462@lists.php.net to get a copy of this message | ||
Ramiro Barrantes <ramiro@precisionbioassay.com> wrote:
>Hello,
>
>I would like to record, on a database, the global variables $_POST and
>$_SERVER for each action that the user does that involves a
>modification of the database. I am just saving, say $_POST or
>$_SERVER (and others), as a string and putting it in a field on the
>database.
>
>However, when I try to get the info out of the database and access it
>as an XML (using the DOMDocument library) it becomes a pain to handle
>due to all the special characters (I think, as I haven't been able to
>get it to work), for example:
>
>Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0
>
>(I seem to need to replace all the "/"s)
>
>It's a pain, and I would like not to have to replace special characters
>with preg_replace if possible.
>
>Any suggestions? I have been having a lot of trouble with this.
>
>Thanks in advance,
>
>Ramiro
Why are you converting the arrays into xml at all? Serialise the data instead, xml is unnecessary
here and will cause you problems as you've found.
Thanks,
Ash