Created
March 9, 2013 13:42
-
-
Save davidrenne/5124199 to your computer and use it in GitHub Desktop.
db connection php script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `database_connections` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`connection_id` int(11) NOT NULL, | |
`queries` text NOT NULL, | |
`page` varchar(300) NOT NULL, | |
`ip_address` varchar(255) NOT NULL, | |
`t_stamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
PRIMARY KEY (`id`), | |
UNIQUE KEY `connection_unique` (`connection_id`), | |
KEY `connection_id` (`connection_id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; | |
mysql_query( | |
" | |
INSERT INTO | |
database_connections | |
SET | |
connection_id = CONNECTION_ID(), | |
queries = '".mysql_real_escape_string($query_string)."', | |
page = '".mysql_real_escape_string($_SERVER['REQUEST_URI'])."', | |
ip_address = '".(!empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : mysql_real_escape_string(print_r($_SERVER,true)))."' | |
ON DUPLICATE KEY UPDATE queries=CONCAT(queries,'\n\n\n','".mysql_real_escape_string($query_string)."'); | |
" | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment