我有一个PHP脚本,抛出此错误解析错误:语法错误,文件意外结束我检查并重新检查代码我找不到任何丢失的分号或括号。请看看,也许你可以看到我错过了什么。
<?php
require_once('./session.php');
require_once('./fileloader.php');
$mysqli = new mysqli("$ip", "$username", "$password", "$db");
$mysqlil = new mysqli("$ipl", "$usernamel", "$passwordl", "$dbl");
// start of post
$name = $_POST["name"];
$pool = $_POST["pool"];
$dns = $_POST["dns"];
$site = $_POST["site"];
$port = $_POST["port"];
// end of post
// start of data sanitize and existence check
if (empty($name)){
// If input feild is empty it goes back to the fourm and informs the user
$_SESSION['exitcodev2'] = 'name';
header('Location: adddhcp.php');
exit;
} elseif(empty($pool)){
// If input feild is empty it goes back to the fourm and informs the user
$_SESSION['exitcodev2'] = 'pool';
header('Location: adddhcp.php');
exit;
}elseif(empty($dns)){
// If input feild is empty it goes back to the fourm and informs the user
$_SESSION['exitcodev2'] = 'dns';
header('Location: adddhcp.php');
exit;
}elseif(empty($site)){
// If input feild is empty it goes back to the fourm and informs the user
$_SESSION['exitcodev2'] = 'site';
header('Location: adddhcp.php');
exit;
}elseif(empty($port)){
// If input feild is empty it goes back to the fourm and informs the user
$_SESSION['exitcodev2'] = 'con';
header('Location: adddhcp.php');
exit;
}else{
//resets the code
$_SESSION['exitcodev2'] = '';
}
$name = $mysqli->real_escape_string($name);
$pool = $mysqli->real_escape_string($pool);
$dns = $mysqli->real_escape_string($dns);
$site = $mysqli->real_escape_string($site);
$portid = $mysqli->real_escape_string($port);
// end of data sanitize and existence check
// start of data entry
if ($result3 = $mysqli->query("SELECT * FROM `device_ports` WHERE `use` = 'mgmt' and `devices_iddevices` = '$site'")) {
/* fetch associative array */
while ($row3 = $result3->fetch_assoc()) {
$portidm= $row3["port id"];
}
}
if ($resultl = $mysqlil->query("SELECT * FROM `ipv4_addresses` WHERE `port_id` = '$portidm'")) {
/* fetch associative array */
while ($rowl = $resultl->fetch_assoc()) {
$routerip= $rowl["ipv4_address"];
}
}
if ($resultl = $mysqlil->query("SELECT * FROM `ipv4_addresses` WHERE `port_id` = '$portid'")) {
/* fetch associative array */
while ($rowl = $resultl->fetch_assoc()) {
$defaultrouter= $rowl["ipv4_address"];
$ipv4network = $rowl["ipv4_network_id"];
}
}
if ($resultl = $mysqlil->query("SELECT * FROM `ipv4_networks` WHERE `ipv4_network_id` = '$ipv4network'")) {
/* fetch associative array */
while ($rowl = $resultl->fetch_assoc()) {
$subnet= $rowl["ipv4_network"];
}
}
$long = ip2long($defaultrouter);
$start = $long +1;
$start =long2ip($start);
$end = $long + $pool + 1;
$end = long2ip($end);
$ssh = new Net_SSH2("$routerip");
if (!$ssh->login("$rname", "$rpass")) {
exit('Login Failed');
}
$ssh->exec("/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper begin\n
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dhcp-server shared-network-name $name authoritative disable\n
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dhcp-server shared-network-name $name subnet $subnet default-router $defaultrouter\n
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dhcp-server shared-network-name $name subnet $subnet dns-server $dns\n
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dhcp-server shared-network-name $name subnet $subnet lease 86400\n
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper set service dhcp-server shared-network-name $name subnet $subnet start $start stop $end\n
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper commit\n
/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper save\n");
if ($mysqli->query("INSERT INTO `$db`.`dhcp_servers` (`idDHCP_Servers`,
`DNS`, `Range_Start`, `Range_Stop`, `subnet`, `name`,
`device_ports_iddevice_ports`) VALUES
(NULL, '$dns', '$start', '$end', '$subnet', '$name', '$portid');") === TRUE) {
//nothing
} else{
echo'Something went wrong with the database please contact your webmaster';
exit;
}
?>