<?php //changes made if (isset($_GET['name'])) { $name = $_GET['name']; } //return $_GET[parameter_name] or '' if it doesn't exist function getStuff($parameter_name, $default = '') { if (isset($_GET[$parameter_name])) { return $_GET[$parameter_name]; } else { return ' '; } } $name = getStuff($x, 'no value'); echo 'name is' . $name; ?> <?php //implement implode function join($glue, $pieces) { $output = ''; foreach ($pieces as $piece) { return $piece . ":"; } }
include_once 'simple_html_dom.php'; $word = array(); $meaning = array(); $dict = array(); $url = "http://www.majortests.com/gre/wordlist_01"; $html = file_get_html($url); for ($i = 1; $i < 16; $i++) { if ($i > 1) { $url = str_replace($i - 1, $i, $url); } if ($i > 9) { $url = str_replace("_0", "_", $url); } $html = file_get_html($url); $someArr = getStuff($html); $word = appendArr($someArr[0], $word); $meaning = appendArr($someArr[1], $meaning); } for ($i = 0; $i < count($word); $i++) { $dict[$word[$i]] = $meaning[$i]; } $link = mysqli_connect('127.0.0.1', 'root', '', 'someDB'); if (!$link) { die("Connect fail: " . mysqli_connect_error()); } //echo "Connection win! "; // create 2 tables $sql = "SHOW TABLES LIKE meaning"; if (!mysqli_query($link, $sql)) { $sql = "CREATE TABLE meaning (tag int(4) unsigned NOT NULL, satMeaning TEXT NOT NULL)";