gpt4 book ai didi

PHP/MYSQL 代码未回显成功

转载 作者:行者123 更新时间:2023-11-30 00:04:21 25 4
gpt4 key购买 nike

嘿伙计,这段代码没有回显插入信息的成功,但只是不回显成功的想法,有帮助吗?

如果您可以发布包含代码修复的答案,那就太好了,谢谢大家的帮助:)

错误代码:

<?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));
}
?>

最佳答案

因此插入已正确完成,但错误阻止了脚本运行,直到行:

echo "status=Success";

尝试将其插入脚本的开头并发布答案:

$debug = true;
ini_set('display_startup_errors', $debug);
ini_set('display_errors', $debug);
ini_set('html_errors', $debug);

顺便问一下,哪个插入完成了?第一次插入users,插入users_items,直到第二次插入users_items?

关于PHP/MYSQL 代码未回显成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24720911/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com