} if (!$stmt->execute()) { exit("Execute failed: (" . $stmt->errno . ") " . $stmt->error); } $stmt->store_result(); if ($stmt->num_rows == 0 || $stmt->num_rows >= 2) { exit("Error: id not found or multiple result found"); } $stmt->bind_result($userid, $lastname, $firstname, $middlename, $suffix, $title, $department, $phone, $email, $photoImageURL, $keywordImageURL, $socialKeywordURL, $description); $stmt->fetch(); $registered = 1; } else { if (isset($name)) { $bind_param_last_name = $parser->getLast(); $bind_param_first_name = $parser->getFirst(); $bind_param_middle_name = $parser->getMiddle(); $bind_param_suffix = $parser->getSuffix(); if (!$stmt->bind_param("ssss", $bind_param_last_name, $bind_param_first_name, $bind_param_middle_name, $bind_param_suffix)) { exit("Binding parameters failed: (" . $stmt->errno . ")" . $stmt->error); } if (!$stmt->execute()) { exit("Execute failed: (" . $stmt->errno . ") " . $stmt->error); } $stmt->store_result(); if ($stmt->num_rows == 1) { $stmt->bind_result($theid, $lastname, $firstname, $middlename, $suffix, $title, $department, $phone, $email, $photoImageURL, $keywordImageURL, $socialKeywordURL, $description); $stmt->fetch(); $registered = 1; } else { if ($stmt->num_rows > 1) { exit("Bad luck: Multiple records match");
public function setFullname($fullname) { $name = new \HumanNameParser_Parser($fullname); $this->customer->setName(new Name($name->getFirst(), $name->getLast(), $name->getMiddle())); return $this; }
if ($expected === '') { $expected = "[empty]"; } if ($actual === '') { $actual = "[empty]"; } if ($actual === $expected) { $ret = "<span class='win'>{$expected} = {$actual}</span>"; } else { $ret = "<span class='fail'>{$expected} ≠ {$actual}</span>"; } return $ret; } $handle = fopen('./Tests/testNames.txt', 'r'); while ($nameArr = fgetcsv($handle, 1000, "|")) { $parser = new HumanNameParser_Parser($nameArr[0]); // check to see if the parser got each name-part correct $ret = testEqual($nameArr[1], $parser->getleadingInit()); $ret .= testEqual($nameArr[2], $parser->getFirst()); $ret .= testEqual($nameArr[3], $parser->getNicknames()); $ret .= testEqual($nameArr[4], $parser->getMiddle()); $ret .= testEqual($nameArr[5], $parser->getLast()); $ret .= testEqual($nameArr[6], $parser->getSuffix()); $divClass = strpos($ret, "class='fail'") ? "fail" : "win"; // a hacky way to do this echo "<div class='name {$divClass}'><h2 class='test-name'>{$nameArr[0]}</h2>{$ret}</div>"; } ?> </body> </html>