Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' )
- {
- // Displays a multi-dimensional array as a HTML unordered lists.
- function displayTree($array)
- {
- $newline = "";
- foreach($array as $key => $value) //cycle through each item in the array as key => value pairs
- {
- if (is_array($value) || is_object($value)) //if the VALUE is an array, then
- {
- //call it out as such, surround with brackets, and recursively call displayTree.
- $value = "Array()" . $newline . "(" . displayTree($value) . ")" . $newline;
- }
- //if value isn't an array, it must be a string. output its' key and value.
- $output .= "[\"$key\"] = " . $value . ",\n" . $newline;
- }
- return $output;
- }
- $con = mysql_connect("extraproclancom.ipagemysql.com","halostatius","!Gameboy01");
- if (!$con)
- {
- die('Could not connect. Error message: ' . mysql_error());
- }
- $db_selected = mysql_select_db("halostats", $con);
- if (!$db_selected)
- {
- die ("Can\'t use database halostats: " . mysql_error());
- }
- //create columns if they don't exist
- foreach ($_POST as $k => $v)
- {
- $query = "SELECT " . $k . " FROM stats";
- $query = mysql_query($query);
- if(!$query)
- {
- $query = "ALTER TABLE `stats` ADD `" . $k . "` " . "TEXT";
- mysql_query($query);
- }
- }
- $hash = $_POST['Hash'];
- echo "SELECT * FROM stats WHERE Hash='$hash';";
- $result = mysql_query("SELECT * FROM stats WHERE Hash='$hash';");
- if(mysql_num_rows($result) == 0)
- {
- $keys = "INSERT INTO `stats` (";
- $values = "VALUES (";
- $bool = true;
- foreach ($_POST as $k => $v)
- {
- if($bool)
- {
- $keys = $keys . "`" . $k . "`";
- $values = $values . "'" . $v . "'";
- $bool = false;
- }
- else
- {
- $keys = $keys . ", `" . $k . "`";
- $values = $values . ", '" . $v . "'";
- }
- }
- $keys = $keys . ") ";
- $values = $values . ")";
- mysql_query($keys . $values);
- //mysql_query("INSERT INTO `stats` (`ip`, `name`, `kills`, `assists`, `deaths`) VALUES ('" . $_POST['ip'] . "', '" . $_POST['name'] . "', '" . $_POST['kills']");");
- }
- else
- {
- foreach ($_POST as $k => $v)
- {
- $query = "UPDATE `stats` set `" . $k . "` = ";
- $query = $query . "'" . $v . "'";
- $query = $query . " WHERE `Hash` = '" . $_POST['Hash'] . "'";
- mysql_query($query);
- }
- }
- mysql_close($con);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement