嘿,这个代码并没有回应它插入信息的成功,但只是没有回应成功心灵的帮助?
如果你的家伙可以通过代码修复发布答案,那将非常感谢大家的帮助:)
错误代码:
<?php
include 'config.inc.php';
$con = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DATA);
if(isset($_POST["strUsername"])) {
/** PREVENTS DATA MANIPULATION **/
$sign['NAME'] = $con->real_escape_string(stripslashes($_POST["strUsername"]));
$sign['PASS'] = $con->real_escape_string(stripslashes($_POST["strPassword"]));
$sign['PASS'] = gen_token($sign['PASS'], $sign['NAME']);
$sign['AGE'] = $con->real_escape_string(stripslashes($_POST["intAge"]));
$sign['DOB'] = $con->real_escape_string(stripslashes($_POST["strDOB"]));
$sign['EMAIL'] = $con->real_escape_string(stripslashes($_POST["strEmail"]));
$sign['GENDER'] = $con->real_escape_string(stripslashes($_POST["strGender"]));
$sign['EYE'] = $con->real_escape_string(stripslashes($_POST["intColorEye"]));
$sign['CLASSID'] = $con->real_escape_string(stripslashes($_POST["ClassID"]));
$sign['SKIN'] = $con->real_escape_string(stripslashes($_POST["intColorSkin"]));
$sign['HAIR'] = $con->real_escape_string(stripslashes($_POST["intColorHair"]));
$sign['ID'] = $con->real_escape_string(stripslashes($_POST['HairID']));
$sql = $con->query("SELECT * FROM users WHERE Username = '{$sign['NAME']}'");
if ($sql->num_rows > 0) {
die("status=Taken&strReason=The username is already in use by another character.");
}
$sql2 = $con->query("SELECT * FROM users WHERE Email = '{$sign['EMAIL']}'");
if ($sql2->num_rows > 0) {
die("status=Taken&strReason=The email is already in use by another character.");
} else {
/** SETS HAIRNAME & HAIRFILE **/
switch ($sign['ID']) {
/** MALE HAIR **/
case 52:
$hairname = 'Default';
$hairfile = 'hair/M/Default.swf';
break;
case 55:
$hairname = 'Goku1';
$hairfile = 'hair/M/Goku1.swf';
break;
case 58:
$hairname = 'Goku2';
$hairfile = 'hair/M/Goku2.swf';
break;
case 92:
$hairname = 'Ponytail8';
$hairfile = 'hair/M/Ponytail8.swf';
break;
case 64:
$hairname = 'Normal2';
$hairfile = 'hair/M/Normal2.swf';
break;
case 349:
$hairname = 'SuggestedHair';
$hairfile = 'hair/M/SuggestedHair.swf';
break;
case 284:
$hairname = 'SandBoy';
$hairfile = 'hair/M/SandBoy.swf';
break;
case 383:
$hairname = 'AQDemonHunter1';
$hairfile = 'hair/M/AQDemonHunter1.swf';
break;
case 396:
$hairname = 'MQElegant';
$hairfile = 'hair/M/MQElegant.swf';
break;
case 390:
$hairname = 'DFWarStyle';
$hairfile = 'hair/M/DFWarStyle.swf';
break;
case 275:
$hairname = 'FauxHawk2';
$hairfile = 'hair/M/FauxHawk2.swf';
break;
case 398:
$hairname = 'MQSwift';
$hairfile = 'hair/M/MQSwift.swf';
break;
case 324:
$hairname = 'Troll3Human';
$hairfile = 'hair/M/Troll3Human.swf';
break;
/** FEMALE HAIR **/
case 14:
$hairname = 'Pig1Bangs1';
$hairfile = 'hair/F/Pig1Bangs1.swf';
break;
case 18:
$hairname = 'Pig2Bangs2';
$hairfile = 'hair/F/Pig2Bangs2.swf';
break;
case 26:
$hairname = 'Pony2Bangs2';
$hairfile = 'hair/F/Pony2Bangs2.swf';
break;
case 83:
$hairname = 'Bangs2Long';
$hairfile = 'hair/F/Bangs2Long.swf';
break;
case 84:
$hairname = 'Bangs3Long';
$hairfile = 'hair/F/Bangs3Long.swf';
break;
case 285:
$hairname = 'SandHairGirl';
$hairfile = 'hair/F/SandHairGirl.swf';
break;
case 379:
$hairname = 'Bangs3Long';
$hairfile = 'hair/F/Bangs3Long.swf';
break;
case 375:
$hairname = 'AQCasual';
$hairfile = 'hair/F/AQCasual.swf';
break;
case 380:
$hairname = 'MQRibbon';
$hairfile = 'hair/F/MQRibbon.swf';
break;
case 277:
$hairname = 'Dragonhawk';
$hairfile = 'hair/F/Dragonhawk.swf';
break;
case 328:
$hairname = 'TrollFem1Human';
$hairfile = 'hair/F/TrollFem1Human.swf';
break;
case 330:
$hairname = 'TrollFem3Human';
$hairfile = 'hair/F/TrollFem3Human.swf';
break;
}
$con->query("INSERT INTO `users` (`Username`, `Password`, `Access`, `ActivationFlag`, `Age`, `Gender`, `Email`, `Level`, `Gold`, `Coins`, `Exp`, `ColorHair`, `ColorSkin`, `ColorEye`, `ColorBase`, `ColorTrim`, `ColorAccessory`, `DateCreated`, `UpgradeExpire`, `UpgradeDays`, `BankSlots`, `HouseSlots`, `BagSlots`, `HairID`, `HairFile`, `HairName`, `Permamute`, `Quests`, `Settings`, `Achievement`, `LastArea`, `Country`) VALUES ('{$sign['NAME']}', '{$sign['PASS']}', '1', '5', '{$sign['AGE']}', '{$sign['GENDER']}', '{$sign['EMAIL']}', '1', '10000', '500', '0', '{$sign['hycc']}', '{$sign['SKIN']}', '{$sign['EYE']}', '0', '0', '0', '2011-05-23 21:02:33', '2011-05-23 21:02:33', '0', '20', '20', '40', '{$sign['ID']}', '${hairfile}', '{$hairname}', '0', '00000000000000000000000000000000000000000000000000', '0', '0', '', 'US')");
/** SELECTS NEW USER ID **/
$sql3 = $con->query("SELECT id FROM users WHERE Username='{$sign['NAME']}'");
$user = $sql3->fetch_assoc();
$user_id = $user['id'];
switch ($sign['CLASSID']) {
case 2: // Warrior
$con->query("INSERT INTO users_items (itemid, userid, equipped, equipment, level, quantity, inbank, enhid) VALUES ('2', '$user_id', '1', 'ar', '1', '1', '0', '1')");
break;
case 4: // Rogue
$con->query("INSERT INTO users_items (itemid, userid, equipped, equipment, level, quantity, inbank, enhid) VALUES ('3', '$user_id', '1', 'ar', '1', '1', '0', '1')");
break;
case 3: // Mage
$con->query("INSERT INTO users_items (itemid, userid, equipped, equipment, level, quantity, inbank, enhid) VALUES ('4', '$user_id', '1', 'ar', '1', '1', '0', '1')");
break;
case 5: // Ranger
$con->query("INSERT INTO users_items (itemid, userid, equipped, equipment, level, quantity, inbank, enhid) VALUES ('5', '$user_id', '1', 'ar', '1', '1', '0', '1')");
break;
}
$con->query("INSERT INTO users_items (itemid, userid, equipped, equipment, level, quantity, inbank, enhid) VALUES ('1', '$user_id', '1', 'Weapon', '1', '1', '0', '1')");
/** SUCCESS **/
echo "status=Success";
}
} else {
die("status=Error&strReason=Invalid Input.");
}
function gen_token($pass, $salt) {
$salt = strtolower($salt);
$str = hash("sha512", $pass.$salt);
$len = strlen($salt);
return strtoupper(substr($str, $len, 17));
}
?>
答案 0 :(得分:0)
所以INSERT是正确的,但是一个bug会阻止脚本直到行:
echo "status=Success";
尝试在脚本的开头插入并发布答案:
$debug = true;
ini_set('display_startup_errors', $debug);
ini_set('display_errors', $debug);
ini_set('html_errors', $debug);
顺便说一句,哪个插入完成了?进入用户,第一次进入users_items,直到第二次插入到users_items?