phenya2017-08-09 19:35:31
phenya, 2017-08-09 19:35:31

A bunch of exec() + mysqli_query(), what's going on here?

There is a large project with complex branched business logic, working in conjunction with php-fpm + nginx. Mysql is used as a database. And in this big project there is a small such problem, which, as such, does not relate to the project itself, but the project now relates to it. Very bad attitude.
- there is an abstract table in the database `table` with fields `id` , `name`
- there is a simple php script that initializes the connection and tries to make a selection

conn = mysqli_connect('localhost', 'user', 'pass', 'db_name');
$res = $conn->query('SELECT * FROM `table` WHERE `id` = 1');

- there is a second php script that runs the first one with exec()
exec('php -f 1.php', $output);

If you now run the 2nd script, then everything will work fine and $output will not be empty. But if we just change the selection in the 1st script in such a way that we get an empty result and execute the 2nd script again, then everything - $output is empty (and there should be an empty object dump). And it just happens that the 1st script "crashes" when calling
$conn->query('SELECT * FROM `table` WHERE `id` = 2');  // пользователя с ИД = 2 не существует

no error, no warning, and no output at all (nothing in the logs either). The 1st script just quietly dies, and the 2nd is forced to show an empty array. Moreover, this behavior is only if the 1st script is launched by calling exec()(shell_exec(), system()), but if the 1st script is called from the console manually (php -f 1.php), then everything is fine will work: the request is gone, and the response came in the form of an empty object.
Well, the question, as usual, is eternal - who is to blame? and what to do? Maybe someone came across? Or do you have any ideas?
php - 5.6.31
with mysql php communicates via mysqlnd (5.0.11-dev - 20120503)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
FalseCode, 2019-03-26

Yes, here both slick and swiper will do

profesor08, 2019-03-26

Vpindyur any you know, when changing the slide, change the content on the left and the numbers. And assign an additional class to the slide to increase it and set the background. slick will do it.

Igor, 2017-08-09

And you don't confuse anything? :)
Even if you make a syntax error in 1.php, then 2.php will work successfully and give it to you in the output:

php -f 2.php
array(2) {
  string(0) ""
  string(87) "Parse error: syntax error, unexpected ')' in 1.php on line 2"

Maybe a problem with 1.php? In any case here:
a $ sign before conn would be nice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question