E
E
Emil2021-10-14 11:06:33
PHP
Emil, 2021-10-14 11:06:33

Why does mysqli_query always return false?

There is a function:

function balance($card,$cvc,$name,$link){
try{
if(empty($card) OR empty($cvc) or empty($name) or empty($link)){
  return false;
}else{
      include("config.php");//конфиг, содержащий инфу для подключения
 $qq = "SELECT `balance` FROM `cards` WHERE `card` = '$card' AND `cvc` = '$cvc' AND `name` = '$name'";//формируем запрос
mysqli_select_db($link,$dbname);//выбираем БД
$res = mysqli_query($link,$qq);//делаем запрос
$res = mysqli_fetch_assoc($res);//преобразование результата в массив
$link->query("INSERT INTO `log`(`operaion`, `SERVER`, `result`) VALUES ('balance','".implode(",",$_SERVER)."','".implode(",", ($res))."')");// лог в базу данных
return $res;//отдаём результат как массив
}
}catch(Exception $e){
  return false;//если произошла ошибка - возвращаем ничего
}

}

But, it returns false.
It worked perfectly on Vertrigoserv.
mysqli_error returns nothing.
I tried everything I could, but the result didn't change.
Server - PHP 5.6, Apache, Ubuntu 18.04

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ipatiev, 2021-10-14
@Fockker

I already answered this question
. But the most terrible thing, of course, is that these people are trusted to work with maps.
Despite the fact that all card data will leak at the same moment when this "service" goes online

E
Emil, 2021-10-15
@MrCheatEugene

The question is closed.
I apologize for the incorrect title of the question, the reason was not mysqli, but catch.
Reason for the error: The $_SERVER array contains information about SSL( Let's Encrypt), and since I got confused in the examples from php.net and scored on line escaping (more specifically, I didn’t understand why sprintf is needed, and instead of seeing what it does with the LINE ABOVE I just scored), MySQL
saw this:
INSERT `log` ... `server` = '<b>Let'sEncrypt</b>'
Fix was suggested in another question: https://qna.habr.com/q/1060794
namely Sergey delphinpro and explained Hanneman's error

spoiler
И да, Fockker, как видишь - ты сам видимо про базы данных знаешь мало чего, плюс обвиняешь всех вокруг, когда твоё решение не помогло одному человеку.
spoiler
И ещё, ДА, КОГДА Я ГОВОРЮ ПЕРЕРЫЛ ВЕСЬ ИНТЕРНЕТ - ЗНАЧИТ, ЧТО Я ПРОЯНДЕКСИЛ И ПРОГУГЛИЛ ВСЁ. НА АНГЛИЙСКОМ И НА РУССКОМ.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question