PHP 版本:5.4.3 MySQLi 版本:5.5.24
我已经盯着这段代码好几天了,修复了很多小错误,但仍然无法弄清楚为什么它不能成功添加到我的数据库中。
破代码:
// All of my posts have been excluded
// Post Example:
// $server = $_POST['server'];
mysqli_query($link, sprintf(
'INSERT INTO `tribe-server-inv`.`serverdb` (' .
//Server Name
'`Record`, `Server`, `Active Server`, `Server Location`, `Deactivated Server`, ' .
//System Overview
'`Operating System`, `Serial Number`, `Model`, `CPU`, `Power Requirements`, `Location`, `Memory`, ' .
'`Total Physical Disk`, ' .
//System Information
'`Antivirus Installed`, `Warrenty Start Date`, `Physical Server`, `Install Date`, `Antivirus Version`, ' .
'`Warrenty End Date`, `Virtual Server`, `Deactivated Date`, ' .
//Availability
'`Operation Availability Days`, `Availability Downtime Days`, `Operation Availability Hours`, ' .
'`Availability Downtime Hours`, ' .
//Support Information
'`Hardware Vender`, `Associated Servers 1`, `System Owner`, `Associated Servers 2`, ' .
'`Database Owner`, `Associated Servers 3`, `Application Owner`, `Associated Servers 4`, ' .
'`Software Owner`, `Associated Servers 5`, ' .
//Network Info
'`IP Address 1`, `MAC Address 1`, `Trunked IP Address 1`, `IP Address 2`, `MAC Address 2`, ' .
'`Trunked IP Address 2`, `IP Address 3`, `MAC Address 3`, `Management Port IP Address`, ' .
'`IP Address 4`, `MAC Address 4`, ' .
//Storage Info
'`Sans Storage 1`, `Sans Storage 1 Drive Space 1`, `Sans 1 Initiator Address`, `Sans Storage 2`, ' .
'`Sans Storage 2 Drive Space 2`, `Sans 2 Initiator Address`, ' .
'`Promise Storage 1`, `Promise Storage 1 Drive Space 1`, `Promise 1 Initiator Address`, ' .
'`Promise Storage 2`, `Promise Storage 2 Drive Space 2`, `Promise 2 Initiator Address`, ' .
//System Backup
'`Appassure`, `Backupexec`, `Other Backup`, `Backup Server`, `Replication Backup Server`, ' .
'`Backup Server Location`, `Replication Backup Location`, `Backup Server Size`, ' .
'`Replication Backup Size`, `Offsite / Archive Backups`, `Backup Image`, `Archive Offsite Location`, ' .
'`Backup Image Location`, `Archive Size`, `Backup Misc Info`, `Backup Daily`, ' .
'`Daily Backup Space Used`, `Backup Weekly`, `Weekly Backup Space Used`, `Backup Quarterly`, ' .
'`Quarterly Backup Space Used`, `Backup Yearly`, `Yearly Backup Space Used`, ' .
//Disaster Recovery
'`Number of Users`, `Daily Bandwidth Consumption`, `Equipment Replacement Time`, ' .
'`Total Local Data Storage`, `Vender Disaster Turn Around`, `Vender Disaster Cost`, ' .
'`Total Network Storage`, `Approximate Tech Hours`, `Est Replacement Cost`, ' .
'`Approximate Total Replacement Time`, `Disaster Recovery Scenario 1 Loss of Software`, ' .
'`Disaster Recovery Scenario 2 Loss of Hardware`, `Application`)' .
//Values
'VALUES ' .
//Server Name
'(NULL, \'%s\', \'%s\', \'%s\', \'%s\', ' .
//System Overview
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
//System Information
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', ' .
//Availability
'\'%s\', \'%s\', \'%s\', \'%s\', ' .
//Support Information
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', \'%s\', ' .
//Network Info
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
//Storage Info
'\'%s\', \'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', ' .
'\'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', ' .
//System Backup
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', ' .
//Disaster Recovery
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', ' .
'\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')',
//Names
mysqli_real_escape_string($link, $server),
mysqli_real_escape_string($link, $activeServer),
mysqli_real_escape_string($link, $serverLocation),
mysqli_real_escape_string($link, $deactiveServer),
//Overview
mysqli_real_escape_string($link, $operating),
mysqli_real_escape_string($link, $serial),
mysqli_real_escape_string($link, $model),
mysqli_real_escape_string($link, $cpu),
mysqli_real_escape_string($link, $powerReq),
mysqli_real_escape_string($link, $location),
mysqli_real_escape_string($link, $memory),
mysqli_real_escape_string($link, $totPhyDisk),
//System Info
mysqli_real_escape_string($link, $antiVirusInstall),
mysqli_real_escape_string($link, $warrentyStart),
mysqli_real_escape_string($link, $phyServer),
mysqli_real_escape_string($link, $installDate),
mysqli_real_escape_string($link, $antiVirusVersion),
mysqli_real_escape_string($link, $warrentyExpire),
mysqli_real_escape_string($link, $virtualServer),
mysqli_real_escape_string($link, $deactivatedDate),
//Availability
mysqli_real_escape_string($link, $availableDays),
mysqli_real_escape_string($link, $downtimeDays),
mysqli_real_escape_string($link, $availableHours),
mysqli_real_escape_string($link, $downtimeHours),
//Support Info
mysqli_real_escape_string($link, $hardwareVendor),
mysqli_real_escape_string($link, $assoServ1),
mysqli_real_escape_string($link, $systemOwner),
mysqli_real_escape_string($link, $assoServ2),
mysqli_real_escape_string($link, $databaseOwn),
mysqli_real_escape_string($link, $assoServ3),
mysqli_real_escape_string($link, $appOwner),
mysqli_real_escape_string($link, $assoServ4),
mysqli_real_escape_string($link, $softwareOwn),
mysqli_real_escape_string($link, $assoServ5),
//Network Info
mysqli_real_escape_string($link, $IP1),
mysqli_real_escape_string($link, $MAC1),
mysqli_real_escape_string($link, $trunk1),
mysqli_real_escape_string($link, $IP2),
mysqli_real_escape_string($link, $MAC2),
mysqli_real_escape_string($link, $trunk2),
mysqli_real_escape_string($link, $IP3),
mysqli_real_escape_string($link, $MAC3),
mysqli_real_escape_string($link, $manPortIP),
mysqli_real_escape_string($link, $IP4),
mysqli_real_escape_string($link, $MAC4),
//Storage
mysqli_real_escape_string($link, $sanStor1),
mysqli_real_escape_string($link, $driveSpace1),
mysqli_real_escape_string($link, $initiatorAddress1),
mysqli_real_escape_string($link, $sanStor2),
mysqli_real_escape_string($link, $driveSpace2),
mysqli_real_escape_string($link, $initiatorAddress2),
mysqli_real_escape_string($link, $promStor1),
mysqli_real_escape_string($link, $promStorSpace1),
mysqli_real_escape_string($link, $prom1InitAddress),
mysqli_real_escape_string($link, $promStor2),
mysqli_real_escape_string($link, $promStorSpace2),
mysqli_real_escape_string($link, $prom2InitAddress),
//System Backup
mysqli_real_escape_string($link, $appAssure),
mysqli_real_escape_string($link, $backupExec),
mysqli_real_escape_string($link, $otherBackup),
mysqli_real_escape_string($link, $backupServ),
mysqli_real_escape_string($link, $repBackupServ),
mysqli_real_escape_string($link, $backupServLoc),
mysqli_real_escape_string($link, $repBackupLoc),
mysqli_real_escape_string($link, $backupSize),
mysqli_real_escape_string($link, $repBackupSize),
mysqli_real_escape_string($link, $archiveBackup),
mysqli_real_escape_string($link, $backupImage),
mysqli_real_escape_string($link, $arcOffsiteLoc),
mysqli_real_escape_string($link, $backupImageLoc),
mysqli_real_escape_string($link, $arcBackSize),
mysqli_real_escape_string($link, $backupMiscInfo),
mysqli_real_escape_string($link, $backupDaily),
mysqli_real_escape_string($link, $dailySpaceUsed),
mysqli_real_escape_string($link, $backupWeekly),
mysqli_real_escape_string($link, $weeklySpaceUsed),
mysqli_real_escape_string($link, $backupQuarter),
mysqli_real_escape_string($link, $quarterlySpaceUsed),
mysqli_real_escape_string($link, $backupYear),
mysqli_real_escape_string($link, $yearlySpaceUsed),
//Disaster Recovery
mysqli_real_escape_string($link, $numUsers),
mysqli_real_escape_string($link, $bandwidth),
mysqli_real_escape_string($link, $equipReplaceTime),
mysqli_real_escape_string($link, $totalLocStor),
mysqli_real_escape_string($link, $vendorTurn),
mysqli_real_escape_string($link, $venDisCost),
mysqli_real_escape_string($link, $totNetStor),
mysqli_real_escape_string($link, $approxTechTime),
mysqli_real_escape_string($link, $estRepCost),
mysqli_real_escape_string($link, $totReplaceTime),
mysqli_real_escape_string($link, $disasterRecover1),
mysqli_real_escape_string($link, $disasterRecover2),
mysqli_real_escape_string($link, $Applications)));
工作代码:
mysqli_query($link, sprintf(
'INSERT INTO serverdb (' .
//Server Name
'Server,' .
'`Server Location`)' .
//Values
'VALUES ' .
//Server Name
'(\'%s\', \'%s\')',
//Names
mysqli_real_escape_string($link, $server),
mysqli_real_escape_string($link, $serverLocation)));
两组代码的结构完全相同,我无法弄清楚它有什么问题。