Skip to content

Instantly share code, notes, and snippets.

@nharrell04
Last active December 21, 2015 16:39
Show Gist options
  • Save nharrell04/6335526 to your computer and use it in GitHub Desktop.
Save nharrell04/6335526 to your computer and use it in GitHub Desktop.
<?php
require_once 'login.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database, $db_server)
or die("Unabale to select database: " . mysql_error());
$url_query = "SELECT url FROM guides";
$url_results = mysql_query($url_query);
if (!$url_results) die ("Database access failed: . mysql_error());
$number_of_rows = mysql_num_rows($url_results);
for ($j = 0; $j < $number_of_rows; ++$j)
{
$fresh_hash = generate_hash((mysql_result($url_results, $j, 'url'));
$add_query = "INSERT INTO guides(hashpipe) VALUES('$fresh_hash');
$add_hash = mysql_query($add_query);
if (!$add_hash) die ("Database access failed: " . mysql_error());
}
function generate_hash($url_var)
{
$new_hash = md5(file_get_contents($url_var));
echo $new_hash;
}
mysql_close($db_server);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment