Answer the question
In order to leave comments, you need to log in
The response from the server to the script is not sent, how to fix it?
I have a table with 3 elements: server, question, answer. I need to return the answer depending on the server and the question,
Could you tell me what I'm doing wrong?
function hook.onShowDialog(dialogID, style, title, button1, button2, text)
if title:find("Капча") then
captchaServer = sampGetCurrentServerName()
captchaServer = captchaServer:match("Diamond Role Play | (.+)")
if captchaServer ~= nil then
if captchaServer:find("Emerald") then
captchaServer = "Emerald"
elseif captchaServer:find("Amber") then captchaServer = "Amber"
elseif captchaServer:find("Trilliant") then captchaServer = "Trilliant"
elseif captchaServer:find("Sapphire") then captchaServer = "Sapphire"
elseif captchaServer:find("Crystal") then captchaServer = "Crystal"
elseif captchaServer:find("Ruby") then captchaServer = "Ruby"
end
end
captchaQuestion = text:match("Вопрос:\n(.+)\n\nВарианты ответа:")
captchaAnswer[1] = text:match("1. (.+)\n2.")
captchaAnswer[2] = text:match("2. (.+)\n3.")
captchaAnswer[3] = text:match("3. (.+)\n4.")
captchaAnswer[4] = text:match("4. (.+)\n\n{FFFFFF}Введите")
sampAddChatMessage("{00A885}анти-капча{ffffff}: делаем запрос к базе данных", -1)
local serverEncoded = urlencode(captchaServer)
local questionEncoded = urlencode(captchaQuestion)
httpRequest('http://localhost/index.php?cap_server_2='..serverEncoded..'&cap_question_2='..questionEncoded, nil, function(response, code, headers, status)
if response then
sampAddChatMessage("{00A885}анти-капча{ffffff}: ищем капчу в базе данных...", -1)
local trueAnswer = decodeJson(response.text)["cap_answer_to_lua"]
sampAddChatMessage('true answer: '..trueAnswer, -1)
else
sampAddChatMessage("{00A885}анти-капча{ffffff}: капча в базе данных не найдена", -1)
end
end)
isCaptchaActive = true
end
end
$cap_server_2 = $_GET["cap_server_2"];
$cap_question_2 = $_GET["cap_question_2"];
$cap_answer_to_lua;
$sql = "SELECT server, question, answer FROM drp_captch WHERE server = '$cap_server_2' AND question = '$cap_question_2'";
$result = $conn->query($sql);
echo $sql;
if ($cap_question_2 && $cap_server_2) {
if ($result->num_rows > 0)
{
$IsCaptchInTable = true;
$row = mysqli_fetch_array($result);
$cap_answer_to_lua = $row["answer"];
echo json_encode( $cap_answer_to_lua );
$result->free();
}
else {
$IsCaptchInTable = false;
}
}
Answer the question
In order to leave comments, you need to log in
Instructions on the PHP side of the view:
$result = $conn->query($sql);
echo $sql; // Именно эта, но не строкой выше!
local trueAnswer = decodeJson(response.text)["cap_answer_to_lua"]
Could you suggest what I am doing wrong?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question