Ошибка function name must be a string php

Using parenthesis in a programming language or a scripting language usually means that it is a function.

However $_COOKIE in php is not a function, it is an Array. To access data in arrays you use square braces (‘[‘ and ‘]’) which symbolize which index to get the data from. So by doing $_COOKIE['test'] you are basically saying: «Give me the data from the index ‘test’.

Now, in your case, you have two possibilities: (1) either you want to see if it is false—by looking inside the cookie or (2) see if it is not even there.

For this, you use the isset function which basically checks if the variable is set or not.

Example

if ( isset($_COOKIE['test'] ) )

And if you want to check if the value is false and it is set you can do the following:

if ( isset($_COOKIE['test']) && $_COOKIE['test'] == "false" )

One thing that you can keep in mind is that if the first test fails, it wont even bother checking the next statement if it is AND ( && ).

And to explain why you actually get the error «Function must be a string», look at this page. It’s about basic creation of functions in PHP, what you must remember is that a function in PHP can only contain certain types of characters, where $ is not one of these. Since in PHP $ represents a variable.

A function could look like this: _myFunction _myFunction123 myFunction and in many other patterns as well, but mixing it with characters like $ and % will not work.

SitePoint Forums | Web Development & Design Community

Loading

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
require_once('php/start_session.php');
if(!isset($_SESSION['user_id']) && empty($_SESSION['user_id'])){
    header("Location: index.php");
    exit();
}
 
 
$page_title = "Редагувати профіль";
require_once('php/header.php');
 
require_once('php/connect.php');
 
require_once('php/menu.php');
 
?>
     <!--Content-->
            <div class="container-fluid container-fluid-edit">
                <div class="container container-edit">
                    <div class="row row-edit">
                       <div class="col-lg-12">
                           <h1>Редагування профілю</h1>
                           <hr>
                       </div>
                       <div class="clearfix"></div>
                       
                       <div class="col-md-4 col-md-offset-1 col-xs-12">
                            <span class="edit-header text-center">
                              <h3>Загальна інформація</h3><hr>
                          </span>        
           
                        <?php
                           $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die("Error to connect");
                           
                           if(isset($_POST['submit'])){                               
                               $hobby = mysqli_real_escape_string($dbc, $trim($_POST['hobby']));
                               
                               $how_long_1 = mysqli_real_escape_string($dbc, $trim($_POST['how_long_1']));
                               $how_long_2 = mysqli_real_escape_string($dbc, $trim($_POST['how_long_2']));
                               $how_long = $how_long_1." ".$how_long_2;
                               
                               $rank = mysqli_real_escape_string($dbc, $trim($_POST['rank']));
                               $what = mysqli_real_escape_string($dbc, $trim($_POST['what']));
                               
                               $zhim = mysqli_real_escape_string($dbc, $trim($_POST['zhim']));
                               $prisyad = mysqli_real_escape_string($dbc, $trim($_POST['prisyad']));
                               $stanova = mysqli_real_escape_string($dbc, $trim($_POST['stanova']));
                               
                               $query = "UPDATE users SET hobby='$hobby', $how_long='$how_long', rank='$rank', what='$what', zhim='$zhim', prisyad='$prisyad', stanova='$stanova' WHERE id_user='".$_SESSION['user_id']."'";
                               
                               mysqli_query($dbc, $query) or die("Querry error");
                               
                           } else {
                               $query = "SELECT * FROM users WHERE id_user='".$_SESSION['user_id']."'";
                               $data = mysqli_query($dbc, $query) or die("Error to query");
                               $row = mysqli_fetch_array($data);
                               
                               if($row != NULL){
                                   $first_name = $row['first_name'];
                                   $last_name = $row['last_name'];
                                   $email = $row['email'];
                                   $birthdate = $row['birthdate'];
                                   $hobby = $row['hobby'];
                                   $how_long = $row['how_long'];
                                   $rank = $row['rank'];
                                   $what = $row['what'];
                                   $zhim = $row['zhim'];
                                   $prisyad = $row['prisyad'];
                                   $stanova = $row['stanova'];
                               }
                           }
 
                        ?>
            
            
          
                           <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
                              <label>Яким видом спорту ви займаєтеся?</label>
                               <div class="checkbox">
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Пауерліфтинг">
                                    Пауерліфтинг &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Бодибілдінг">
                                    Бодибілдінг &nbsp;
                                  </label><br>
                                   <label>
                                    <input name="hobby[]" type="checkbox" value="Важка атлетика">
                                    Важка атлетика &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Легка атлетика">
                                    Легка атлетика &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Командні види спорту">
                                    Командні види спорту &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Зимові види спорту ">
                                    Зимові види спорту &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Бойові мистецтва">
                                    Бойові мистецтва &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Плавання">
                                    Плавання &nbsp;
                                  </label><br>
                                </div><hr>
                                <div class="form-inline">
                                    <label for="how_long">Скільки часу займаєтеся?</label><br>
                                    <select class="form-control" name="how_long_1" id="how_long_1">
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <option value="6">6</option>
                                        <option value="7">7</option>
                                        <option value="8">8</option>
                                        <option value="9">9</option>
                                        <option value="10">10</option>
                                        <option value="11">11</option>
                                        <option value="12">12</option>                
                                    </select>
                                    <select class="form-control" name="how_long_2" id="how_long_2">
                                        <option value="Місяць(-ів)">Місяць(-ів)</option>
                                        <option value="Рік(-ів)">Рік(-ів)</option>              
                                    </select>
                                </div>
                                <hr>
                                <label>Чи маєте якесь звання?</label>
                                <div class="radio">
                                  <label>
                                    <input type="radio" name="rank" value="МСМК" <?php if(!empty($rank) && $rank="МСМК") echo 'checked'; ?> >
                                    МСМК &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="МС" <?php if(!empty($rank) && $rank="МС") echo 'checked'; ?>>
                                    МС &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="КМС" <?php if(!empty($rank) && $rank="КМС") echo 'checked'; ?>>
                                    КМС &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="1 розряд" <?php if(!empty($rank) && $rank="1 розряд") echo 'checked'; ?>>
                                    1 розряд &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="Немає" <?php if(!empty($rank) && $rank="Немає") echo 'checked'; ?>>
                                    Немає &nbsp;
                                  </label>
                                </div>
                                <hr>
                                <div class="form-group">
                                    <label for="what">Що вас спонукало до занять спортом?</label>
                                    <input type="text" class="form-control" name="what" id="what" placeholder="Наприклад: Саморозвиток">
                                </div>
                                <hr>
                                <h4>Силові показники</h4><hr>
                                <div class="form-group">
                                    <label for="zhim">Жим лежачи (кг)</label>
                                    <input type="text" class="form-control" name="zhim_lezha" id="zhim_lezha" placeholder="Наприклад: 100">
                                    <label for="prisyad">Присяд (кг)</label>
                                    <input type="text" class="form-control" name="prisyad" id="prisyad" placeholder="Наприклад: 300">
                                    <label for="stanova">Станова тяга (кг)</label>
                                    <input type="text" class="form-control" name="stanova" id="stanova" placeholder="Наприклад: 200">
                                </div>
                                <hr>
                               <input type="submit" name="submit" class="btn btn-primary" value="Змінити">
                           </form>
                       </div>
                       
                       
                       <div class="col-lg-1"></div>
                       <div class="col-lg-1"></div>
                       <div class="col-lg-4 col-xs-12">
                          <span class="edit-header text-center">
                              <h3>Приватна інформація</h3><hr>
                          </span>
                           <form>
                               <div class="form-group">
                                   <label for="u_name">Ім'я та фамілія</label>
                                   <input type="text" name="u_last" class="form-control" id="u_name" placeholder="Ім'я">
                               </div>
                               <div class="form-group">
                                   <input type="text" name="u_last" class="form-control" id="u_last" placeholder="Фамілія">
                               </div>
                               <hr>
                               <div class="clearfix"></div>
                               <div class="form-group">
                                   <label for="u_password1">Зміна паролю</label>
                                   <input type="password" name="u_password1" class="form-control" id="u_password1" placeholder="Пароль">
                               </div>
                               <div class="form-group">
                                   <input type="password" name="u_password2" class="form-control" id="u_password2" placeholder="Повторіть пароль">
                               </div>
                               <hr>
                               <div class="clearfix"></div>
                               <div class="form-group">
                                   <label for="u_email">Email:</label>
                                   <input type="password" name="u_email" class="form-control" id="u_email" placeholder="Email">
                               </div>
                               <hr>
                               <button class="btn btn-primary btn-block">Змінити</button>
                           </form>
                       </div>
                       
                       <div class="col-lg-1"></div>
                    </div>
                </div>
            </div>
            <!--Content-->
            
<?php
require_once('php/footer.php');
?>

This is a short guide on how to fix the following fatal error in PHP:

Fatal error: Function name must be a string

At first, you might think that your PHP code contains a function that hasn’t been named properly. However, that isn’t actually the case. Instead, this error means one of two things:

  1. You are attempting to reference an array as if it were a function.
  2. You are trying to reference an anonymous function that does not exist.

Incorrectly referencing an array.

Take a look at the following example:

//This will cause a fatal error
if($_GET('page') >= 1){
    //do something
}

In the code snippet above, we are attempting to reference a key called “page” inside the $_GET array. However, we made the mistake of using rounded brackets instead of square brackets.

Remember: Rounded brackets are for function calls and square brackets are for referencing array keys.

As a result, a fatal error will be thrown. This is because $_GET is an array, not a string. Therefore, we can not use it as a function call.

In PHP, if you want to reference an array element, you must use square brackets. In order to fix this error, we must replace our rounded brackets with square brackets:

//A fixed version
if($_GET['page'] >= 1){
    //do something
}

This error is particularly common among beginner developers who are attempting to reference superglobal arrays such as $_GET, $_POST, $_FILES, $_SESSION and $_COOKIE.

Here is another example, this time with the $_SESSION array:

//This will fail
echo $_SESSION('name');

This error will also occur if you incorrectly reference a custom array:

<?php

//An example array
$myArray = array(
    'Cat', 'Dog', 'Horse'
);

//Attempting to print out the
//first element
echo $myArray(0);

If you run the PHP code above on your own server, you will encounter the following:

Fatal error: Function name must be a string in /path/to/your/file.php on line 10

This is because we attempted to reference our array using rounded brackets. The fix in this case is to simply use square brackets instead:

//Doing it the right away.
echo $myArray[0];

Referencing an anonymous function that doesn’t exist.

In PHP, you can also create anonymous functions and then reference them like so:

//Creating an anonymous PHP function
$anonFunction = function(){
    echo 'Hello World!';
};

//Calling said function
$anonFunction();

The above piece of code works because we assigned a function to the variable $anonFunction.

However, if we make a mistake and reference the function by the wrong name, our code will spit out a fatal error:

//There is a typo in my
//variable name
$anoFunction();

Here, you can see that I have a typo in my variable name. As a result, the variable equates to null and a fatal error is thrown. This is because a function name must be a string. It cannot be a null value.

Код из темы для wp, для которой давно нет обновлений.
$out .= $this->$value['type']( $value );

PHP Fatal error: Uncaught Error: Function name must be a string in C:OpenServerdomainsfrawp-contentthemesim-startupframeworkadminclassesshortcode-generator.php:140
Stack trace:
#0 C:OpenServerdomainsfrawp-adminincludestemplate.php(1343): missShortcodeMetaBox->show(Object(WP_Post), Array)
#1 C:OpenServerdomainsfrawp-adminincludespost.php(2262): do_meta_boxes(Object(WP_Screen), ‘normal’, Object(WP_Post))
#2 C:OpenServerdomainsfrawp-adminedit-form-blocks.php(409): the_block_editor_meta_boxes()
#3 C:OpenServerdomainsfrawp-adminpost.php(179): include(‘C:OpenServerd…’)
#4 {main}
thrown in C:OpenServerdomainsfrawp-contentthemesim-startupframeworkadminclassesshortcode-generator.php on line 140


  • Вопрос задан

    более трёх лет назад

  • 603 просмотра

Пригласить эксперта

PHP до 7 версии интерпретировала подобные вырожения как: $this->{$value['type']}( $value ). Начиная с 7 версии и выше — ($this->$value)['type']( $value ).
Используйте явный синтаксис(фигурные скобки), чтобы код выполнялся как в 5 версии. Пример

$functionName = $this->$value['type'];
$out .= $functionName($value)

  • Показать ещё
    Загружается…

09 февр. 2023, в 18:25

5000 руб./за проект

09 февр. 2023, в 18:23

2500 руб./за проект

09 февр. 2023, в 17:54

1000 руб./за проект

Минуточку внимания

За последние 24 часа нас посетили 11467 программистов и 1168 роботов. Сейчас ищут 307 программистов …

  1. С нами с:
    27 ноя 2018
    Сообщения:
    2
    Симпатии:
    0

    Доброго времени суток.

    Пытаюсь мигрировать с php 5 на 7ю версию, столкнулся со следующей проблемой. Выпадает следующая ошибка:

    1. Fatal error: Uncaught Error: [] operator not supported for strings in

    2. /usr/share/httpd/html/xmpp/XMLStream.php:467 Stack trace:

    3. #0 /usr/share/httpd/html/cu.php(17): XMPPHP_XMLStream->processUntil(Array)

    4. #1 /usr/share/httpd/html/cu.php(7): sendMessage(‘Well done’)

    5. #2 {main} thrown in /usr/share/httpd/html/xmpp/XMLStream.php on line 467

    1. public function processUntil($event, $timeout=-1) {

    2. $event = array($event);      //   < строка 467

    3. $event_key = key($this->until);

    4. $this->until_count[$event_key] = 0;

    5. while (!$this->disconnected and $this->until_count[$event_key] < 1 and (time() $start < $timeout or $timeout == 1)) {

    6. $payload = $this->until_payload[$event_key];

    7. unset($this->until_payload[$event_key]);

    8. unset($this->until_count[$event_key]);

    9. unset($this->until[$event_key]);

  2. Команда форума
    Модератор

    С нами с:
    25 июл 2013
    Сообщения:
    12.162
    Симпатии:
    1.770
    Адрес:
    :сердА

    Перепроверьте, тот ли файл. Потому что ошибка не имеет ничего общего с происходящим в этой строке.

  3. С нами с:
    4 фев 2018
    Сообщения:
    3.400
    Симпатии:
    510

    Думаю ошибка в +1. $this->until строка а ты применяешь к ней []

  4. С нами с:
    27 ноя 2018
    Сообщения:
    2
    Симпатии:
    0

    Исправил

    на

    заработало

    Ещё одна ошибка в 571 строке

    1. Fatal error: Uncaught Error: Function name must be a string in /usr/share/httpd/html/xmpp/XMLStream.php:571

    2. #0 [internal function]: XMPPHP_XMLStream->endXML(Resource id

    3. #1 /usr/share/httpd/html/xmpp/XMLStream.php(422): xml_parse(Resource id

    4. #1, ‘<stream:feature…’, false)

    5. #2 /usr/share/httpd/html/xmpp/XMLStream.php(474): XMPPHP_XMLStream->__process()

    6. #3 /usr/share/httpd/html/cu.php(17): XMPPHP_XMLStream->processUntil(Array)

    7. #4 /usr/share/httpd/html/cu.php(7): sendMessage(‘Well’)

    8. #5 {main} thrown in /usr/share/httpd/html/xmpp/XMLStream.php on line 571

    29 строка в этом контексте кода и 571 в моём файле, в комментариях указал.

    1. public function endXML($parser, $name) {

    2. #$this->log->log(«Ending $name»,  XMPPHP_Log::LEVEL_DEBUG);

    3. $this->been_reset = false;

    4. if ($this->xml_depth == 1) {

    5. #$found = false; #FIXME This didn’t appear to be in use —Gar

    6. foreach ($this->xpathhandlers as $handler) {

    7. $searchxml = $this->xmlobj[2];

    8. if (($nstag[0] == null or $searchxml->ns == $nstag[0]) and ($nstag[1] == «*» or $nstag[1] == $searchxml->name)) {

    9. foreach ($handler[0] as $nstag) {

    10. if ($searchxml !== null and $searchxml->hasSub($nstag[1], $ns = $nstag[0])) {

    11. $searchxml = $searchxml->sub($nstag[1], $ns = $nstag[0]);

    12. if ($searchxml !== null) {

    13. if ($handler[2] === null)

    14. $this->log->log(«Calling {$handler[1]}«, XMPPHP_Log::LEVEL_DEBUG);

    15. $handler[2]->$handler[1]($this->xmlobj[2]);  /// <<<<  571 строка с ошибкой

    16. foreach ($this->nshandlers as $handler) {

    17. if ($handler[4] != 1 and array_key_exists(2, $this->xmlobj) and $this->xmlobj[2]->hasSub($handler[0])) {

    18. $searchxml = $this->xmlobj[2]->sub($handler[0]);

    19. $searchxml = $this->xmlobj[2];

    20. if ($searchxml !== null and $searchxml->name == $handler[0] and ($searchxml->ns == $handler[1] or (!$handler[1] and $searchxml->ns == $this->default_ns))) {

    21. if ($handler[3] === null)

    22. $this->log->log(«Calling {$handler[2]}«, XMPPHP_Log::LEVEL_DEBUG);

    23. $handler[3]->$handler[2]($this->xmlobj[2]);

    24. foreach ($this->idhandlers as $id => $handler) {

    25. if (array_key_exists(‘id’, $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs[‘id’] == $id) {

    26. if ($handler[1] === null)

    27. $handler[1]->$handler[0]($this->xmlobj[2]);

    28. #id handlers are only used once

    29. unset($this->idhandlers[$id]);

    30. if (isset($this->xmlobj[0]) && $this->xmlobj[0] instanceof XMPPHP_XMLObj) {

    31. $this->xmlobj[0]->subs = null;

    32. if ($this->xml_depth == 0 and !$this->been_reset) {

    33. if (!$this->disconnected) {

    34. if (!$this->sent_disconnect) {

    35. $this->send($this->stream_end);

    36. $this->disconnected = true;

    37. $this->sent_disconnect = true;

    38. $this->event(‘end_stream’);

    Заранее спасибо за помощь

  5. С нами с:
    4 фев 2018
    Сообщения:
    3.400
    Симпатии:
    510
    1. $handler[2]->{$handler[1]}($this->xmlobj[2]);

  6. С нами с:
    1 ноя 2016
    Сообщения:
    1.524
    Симпатии:
    345
  7. С нами с:
    20 июн 2019
    Сообщения:
    1
    Симпатии:
    0

    Ошибку вызывают пустые скобки [] . А так как эта конструкция часто используется для формирования числового массива в цикле, то заполняем их при помощи дополнительной переменной
    <?
    $d = 0;
    for($arResult as $item):
    $arName[$d] = $item[‘NAME’];
    $d++;
    endforeach;
    unset($d);
    ?>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
require_once('php/start_session.php');
if(!isset($_SESSION['user_id']) && empty($_SESSION['user_id'])){
    header("Location: index.php");
    exit();
}
 
 
$page_title = "Редагувати профіль";
require_once('php/header.php');
 
require_once('php/connect.php');
 
require_once('php/menu.php');
 
?>
     <!--Content-->
            <div class="container-fluid container-fluid-edit">
                <div class="container container-edit">
                    <div class="row row-edit">
                       <div class="col-lg-12">
                           <h1>Редагування профілю</h1>
                           <hr>
                       </div>
                       <div class="clearfix"></div>
                       
                       <div class="col-md-4 col-md-offset-1 col-xs-12">
                            <span class="edit-header text-center">
                              <h3>Загальна інформація</h3><hr>
                          </span>        
           
                        <?php
                           $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die("Error to connect");
                           
                           if(isset($_POST['submit'])){                               
                               $hobby = mysqli_real_escape_string($dbc, $trim($_POST['hobby']));
                               
                               $how_long_1 = mysqli_real_escape_string($dbc, $trim($_POST['how_long_1']));
                               $how_long_2 = mysqli_real_escape_string($dbc, $trim($_POST['how_long_2']));
                               $how_long = $how_long_1." ".$how_long_2;
                               
                               $rank = mysqli_real_escape_string($dbc, $trim($_POST['rank']));
                               $what = mysqli_real_escape_string($dbc, $trim($_POST['what']));
                               
                               $zhim = mysqli_real_escape_string($dbc, $trim($_POST['zhim']));
                               $prisyad = mysqli_real_escape_string($dbc, $trim($_POST['prisyad']));
                               $stanova = mysqli_real_escape_string($dbc, $trim($_POST['stanova']));
                               
                               $query = "UPDATE users SET hobby='$hobby', $how_long='$how_long', rank='$rank', what='$what', zhim='$zhim', prisyad='$prisyad', stanova='$stanova' WHERE id_user='".$_SESSION['user_id']."'";
                               
                               mysqli_query($dbc, $query) or die("Querry error");
                               
                           } else {
                               $query = "SELECT * FROM users WHERE id_user='".$_SESSION['user_id']."'";
                               $data = mysqli_query($dbc, $query) or die("Error to query");
                               $row = mysqli_fetch_array($data);
                               
                               if($row != NULL){
                                   $first_name = $row['first_name'];
                                   $last_name = $row['last_name'];
                                   $email = $row['email'];
                                   $birthdate = $row['birthdate'];
                                   $hobby = $row['hobby'];
                                   $how_long = $row['how_long'];
                                   $rank = $row['rank'];
                                   $what = $row['what'];
                                   $zhim = $row['zhim'];
                                   $prisyad = $row['prisyad'];
                                   $stanova = $row['stanova'];
                               }
                           }
 
                        ?>
            
            
          
                           <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
                              <label>Яким видом спорту ви займаєтеся?</label>
                               <div class="checkbox">
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Пауерліфтинг">
                                    Пауерліфтинг &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Бодибілдінг">
                                    Бодибілдінг &nbsp;
                                  </label><br>
                                   <label>
                                    <input name="hobby[]" type="checkbox" value="Важка атлетика">
                                    Важка атлетика &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Легка атлетика">
                                    Легка атлетика &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Командні види спорту">
                                    Командні види спорту &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Зимові види спорту ">
                                    Зимові види спорту &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Бойові мистецтва">
                                    Бойові мистецтва &nbsp;
                                  </label><br>
                                  <label>
                                    <input name="hobby[]" type="checkbox" value="Плавання">
                                    Плавання &nbsp;
                                  </label><br>
                                </div><hr>
                                <div class="form-inline">
                                    <label for="how_long">Скільки часу займаєтеся?</label><br>
                                    <select class="form-control" name="how_long_1" id="how_long_1">
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <option value="6">6</option>
                                        <option value="7">7</option>
                                        <option value="8">8</option>
                                        <option value="9">9</option>
                                        <option value="10">10</option>
                                        <option value="11">11</option>
                                        <option value="12">12</option>                
                                    </select>
                                    <select class="form-control" name="how_long_2" id="how_long_2">
                                        <option value="Місяць(-ів)">Місяць(-ів)</option>
                                        <option value="Рік(-ів)">Рік(-ів)</option>              
                                    </select>
                                </div>
                                <hr>
                                <label>Чи маєте якесь звання?</label>
                                <div class="radio">
                                  <label>
                                    <input type="radio" name="rank" value="МСМК" <?php if(!empty($rank) && $rank="МСМК") echo 'checked'; ?> >
                                    МСМК &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="МС" <?php if(!empty($rank) && $rank="МС") echo 'checked'; ?>>
                                    МС &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="КМС" <?php if(!empty($rank) && $rank="КМС") echo 'checked'; ?>>
                                    КМС &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="1 розряд" <?php if(!empty($rank) && $rank="1 розряд") echo 'checked'; ?>>
                                    1 розряд &nbsp;
                                  </label>
                                  <label>
                                    <input type="radio" name="rank" value="Немає" <?php if(!empty($rank) && $rank="Немає") echo 'checked'; ?>>
                                    Немає &nbsp;
                                  </label>
                                </div>
                                <hr>
                                <div class="form-group">
                                    <label for="what">Що вас спонукало до занять спортом?</label>
                                    <input type="text" class="form-control" name="what" id="what" placeholder="Наприклад: Саморозвиток">
                                </div>
                                <hr>
                                <h4>Силові показники</h4><hr>
                                <div class="form-group">
                                    <label for="zhim">Жим лежачи (кг)</label>
                                    <input type="text" class="form-control" name="zhim_lezha" id="zhim_lezha" placeholder="Наприклад: 100">
                                    <label for="prisyad">Присяд (кг)</label>
                                    <input type="text" class="form-control" name="prisyad" id="prisyad" placeholder="Наприклад: 300">
                                    <label for="stanova">Станова тяга (кг)</label>
                                    <input type="text" class="form-control" name="stanova" id="stanova" placeholder="Наприклад: 200">
                                </div>
                                <hr>
                               <input type="submit" name="submit" class="btn btn-primary" value="Змінити">
                           </form>
                       </div>
                       
                       
                       <div class="col-lg-1"></div>
                       <div class="col-lg-1"></div>
                       <div class="col-lg-4 col-xs-12">
                          <span class="edit-header text-center">
                              <h3>Приватна інформація</h3><hr>
                          </span>
                           <form>
                               <div class="form-group">
                                   <label for="u_name">Ім'я та фамілія</label>
                                   <input type="text" name="u_last" class="form-control" id="u_name" placeholder="Ім'я">
                               </div>
                               <div class="form-group">
                                   <input type="text" name="u_last" class="form-control" id="u_last" placeholder="Фамілія">
                               </div>
                               <hr>
                               <div class="clearfix"></div>
                               <div class="form-group">
                                   <label for="u_password1">Зміна паролю</label>
                                   <input type="password" name="u_password1" class="form-control" id="u_password1" placeholder="Пароль">
                               </div>
                               <div class="form-group">
                                   <input type="password" name="u_password2" class="form-control" id="u_password2" placeholder="Повторіть пароль">
                               </div>
                               <hr>
                               <div class="clearfix"></div>
                               <div class="form-group">
                                   <label for="u_email">Email:</label>
                                   <input type="password" name="u_email" class="form-control" id="u_email" placeholder="Email">
                               </div>
                               <hr>
                               <button class="btn btn-primary btn-block">Змінити</button>
                           </form>
                       </div>
                       
                       <div class="col-lg-1"></div>
                    </div>
                </div>
            </div>
            <!--Content-->
            
<?php
require_once('php/footer.php');
?>

If you want to run your Magento 1.x website on PHP7, you need to make some little tweaks in your some Magento 1.x files to make it work without any issues.

Most of Magento code is still valid in PHP 7, there are few incompatibilities listed below:

1. Uniform Variable Syntax issues:

1.1 app/code/core/Mage/Core/Model/Layout.php:555

This file causes and fatal error which crashes Magento. Override the file and
replace

$out .= $this->getBlock($callback[0])->$callback[1]();

with

$out .= $this->getBlock($callback[0])->{$callback[1]}();

1.2 appcodecoreMageImportExportModelImportUploader.php:135

This file effects Magento CSV importer. Override the file, then override _validateFile() function and replace the line 135 with
replace

$params['object']->$params['method']($filePath);

with

$params['object']->{$params['method']}($filePath);

1.3 appcodecoreMageImportExportModelExportEntityProductTypeAbstract.php:99

This issue effect export functionality of Magento. Magento extends three classes from above abstract class, so root cause of error inside below class is the line#99 in above class.

Mage_ImportExport_Model_Export_Entity_Product_Type_Configurable
Mage_ImportExport_Model_Export_Entity_Product_Type_Grouped
Mage_ImportExport_Model_Export_Entity_Product_Type_Simple

We need to override above three classes in our local code pool and override overrideAttribute() function, replace line#99

$data['filter_options'] = $this->$data['options_method']();

with

$data['filter_options'] = $this->{$data['options_method']}();

1.4 appcodecoreMageImportExportModelExportEntityCustomer.php:250

This file effects export customers functionality. Override above file and change the line#250 as shown below

$data['filter_options'] = $this->$data['options_method']();

with

$data['filter_options'] = $this->{$data['options_method']}();

1.5 libVarienFileUploader.php:259

File uploading will not work. Magento extends Mage_Core_Model_File_Uploader from above class, so we need to override this class and rewrite _validateFile() function replace below line

$params['object']->$params['method']($this->_file['tmp_name']);

with

$params['object']->{$params['method']}($this->_file['tmp_name']);

2. Type casting Issue

2.1 appcodecoreMageCoreModelResourceSession.php:218

Magento Sessions don’t work on PHP 7, so as a result user login doesn’t work.
read($sessId) function should return a string so typecast the return variable as given below

return $data;

with

return (string)$data;

3. Incorrect Grand Total

Incorrect totals are due to wrong sort order of subtotal, discount, shipping etc
Correct the sort order by creating an extension and put below code in config.xml of the extension

<global>
<sales>
<quote>
<totals>
<msrp>
<before>grand_total</before>
</msrp>
<shipping>
<after>subtotal,freeshipping,tax_subtotal,msrp</after>
</shipping>
</totals>
</quote>
</sales>
</global>

Here is the original reference to what I posted above:
http://scriptbaker.com/tag/magento-1-9/

If you cannot find any query in your code, so this will be covered by Magento and as I said before, most of the code is valid so you may just ignore it. I believe thats all can answer your question.

The wrong line is clearly:

$sql_query = $mysqli($sql_code) or die ($mysqli->error);

The error message has also been corrected, from $mysqli->erro to $mysqli->error .

Let’s consider that $mysqli is the connection object with the database and it was created in the conexao.php file. If this premise is wrong, nothing in your code makes sense. If you are right, in the above line you are passing $sql_code to the object $mysqli :

$mysqli($sql_code)

This does not make sense. For you to execute a SQL command, you need to invoke the query method of this object. Assuming you are using the MySQL OOP syntax, it would look like this:

$mysqli->query($sql_code)

This would solve the current error, but would generate another, because your SQL command is wrong:

SELECT senha,login FROM usuario ->' $_SESSION[login]'

You used this arrow syntax that does not exist in SQL. Probably what you wanted to do is:

SELECT senha, login FROM usuario WHERE login = '{$_SESSION[login]}'

Notice the use of the WHERE clause, the identification of the login column, and the use of the = operator.

The last condition of the code also makes no sense:

if (count($erro ==0 || !isset($erro))) { ... }

You are passing the return from the x || y operation, which will be a boolean type, to the count function. Do you want to count the elements of a boolean? No. Probably what you wanted to do is:

if ((count($erro) == 0) || !isset($erro)) { ... }

But there is also no reason to do so. The second operand will check for the non-existence of the variable $erro , but it is defined in line 2, that is, it will always exist. Therefore, !isset($erro) will always return False , regardless of the value of $erro . To check for any error messages, just count :

if (count($error) == 0) { ... }

02.08.2017 / 21:34

When you get this error it is because the module is not picked up by Magento.

Ensure that the files are in place either by adding the manually or using modman. You can use modman repair to verify that files and dirs are linked correctly.

If using modman ensure symlinks are enabled.

Ensure that the webuser has rights to read all files (also the ones in the modman modules dir if you have one). THIS WAS THE PROBLEM FOR ME

Use n98-magerun.phar dev:module:list to verify that Inchoo_PHP7 is on the list. If it is not try to add it: n98-magerun.phar dev:module:enable Inchoo_PHP7.

Use n98-magerun.phar dev:module:rewrite:conflicts to ensure that this module isn’t conflicting with other modules you’ve installed.

If not check that rewrites are also registered n98-magerun.phar dev:module:rewrite:list:

| helpers        | core/data                                                        | Inchoo_PHP7_Helper_Data                                                                                                                        |
| models         | core/layout                                                      | Inchoo_PHP7_Model_Layout                                                                                                                       |
| models         | importexport/import_uploader                                     | Inchoo_PHP7_Model_Import_Uploader                                                                                                              |
| models         | importexport/export_entity_product_type_configurable             | Inchoo_PHP7_Model_Export_Entity_Product_Type_Configurable                                                                                      |
| models         | importexport/export_entity_product_type_grouped                  | Inchoo_PHP7_Model_Export_Entity_Product_Type_Grouped                                                                                           |
| models         | importexport/export_entity_product_type_simple                   | Inchoo_PHP7_Model_Export_Entity_Product_Type_Simple                                                                                            |
| models         | importexport/export_entity_customer                              | Inchoo_PHP7_Model_Export_Entity_Customer                                                                                                       |
| models         | catalog/product_link_api_v2                                      | Inchoo_PHP7_Model_Product_Link_Api_V2                                                                                                          |

За последние 24 часа нас посетили 12160 программистов и 1189 роботов. Сейчас ищут 587 программистов …


  1. Fatth

    С нами с:
    27 ноя 2018
    Сообщения:
    2
    Симпатии:
    0

    Доброго времени суток.

    Пытаюсь мигрировать с php 5 на 7ю версию, столкнулся со следующей проблемой. Выпадает следующая ошибка:

    1. Fatal error: Uncaught Error: [] operator not supported for strings in
    2. /usr/share/httpd/html/xmpp/XMLStream.php:467 Stack trace:
    3. #0 /usr/share/httpd/html/cu.php(17): XMPPHP_XMLStream->processUntil(Array)
    4. #1 /usr/share/httpd/html/cu.php(7): sendMessage(‘Well done’)
    5. #2 {main} thrown in /usr/share/httpd/html/xmpp/XMLStream.php on line 467

    1.   public function processUntil($event, $timeout=-1) {
    2.       $event = array($event);      //   < строка 467
    3.     $event_key = key($this->until);
    4.     $this->until_count[$event_key] = 0;
    5.     while (!$this->disconnected and $this->until_count[$event_key] < 1 and (time() $start < $timeout or $timeout == 1)) {
    6.       $payload = $this->until_payload[$event_key];
    7.       unset($this->until_payload[$event_key]);
    8.       unset($this->until_count[$event_key]);
    9.       unset($this->until[$event_key]);


  2. Fell-x27

    Команда форума
    Модератор

    С нами с:
    25 июл 2013
    Сообщения:
    12.162
    Симпатии:
    1.770
    Адрес:
    :сердА

    Перепроверьте, тот ли файл. Потому что ошибка не имеет ничего общего с происходящим в этой строке.


  3. nospiou

    С нами с:
    4 фев 2018
    Сообщения:
    3.400
    Симпатии:
    510

    Думаю ошибка в +1. $this->until строка а ты применяешь к ней []


  4. Fatth

    С нами с:
    27 ноя 2018
    Сообщения:
    2
    Симпатии:
    0

    Исправил

    на

    заработало

    Ещё одна ошибка в 571 строке

    1. Fatal error: Uncaught Error: Function name must be a string in /usr/share/httpd/html/xmpp/XMLStream.php:571
    2. #0 [internal function]: XMPPHP_XMLStream->endXML(Resource id
    3. #1 /usr/share/httpd/html/xmpp/XMLStream.php(422): xml_parse(Resource id
    4. #1, ‘<stream:feature…’, false)
    5. #2 /usr/share/httpd/html/xmpp/XMLStream.php(474): XMPPHP_XMLStream->__process()
    6. #3 /usr/share/httpd/html/cu.php(17): XMPPHP_XMLStream->processUntil(Array)
    7. #4 /usr/share/httpd/html/cu.php(7): sendMessage(‘Well’)
    8. #5 {main} thrown in /usr/share/httpd/html/xmpp/XMLStream.php on line 571

    29 строка в этом контексте кода и 571 в моём файле, в комментариях указал.

    1.   public function endXML($parser, $name) {
    2.   #$this->log->log(«Ending $name»,  XMPPHP_Log::LEVEL_DEBUG);
    3.   $this->been_reset = false;
    4.   if ($this->xml_depth == 1) {
    5.  #$found = false; #FIXME This didn’t appear to be in use —Gar
    6.  foreach ($this->xpathhandlers as $handler) {
    7.   $searchxml = $this->xmlobj[2];
    8.   if (($nstag[0] == null or $searchxml->ns == $nstag[0]) and ($nstag[1] == «*» or $nstag[1] == $searchxml->name)) {
    9.   foreach ($handler[0] as $nstag) {
    10.   if ($searchxml !== null and $searchxml->hasSub($nstag[1], $ns = $nstag[0])) {
    11.   $searchxml = $searchxml->sub($nstag[1], $ns = $nstag[0]);
    12.   if ($searchxml !== null) {
    13.   if ($handler[2] === null)
    14.   $this->log->log(«Calling {$handler[1]}«, XMPPHP_Log::LEVEL_DEBUG);
    15.   $handler[2]->$handler[1]($this->xmlobj[2]);  /// <<<<  571 строка с ошибкой
    16.   foreach ($this->nshandlers as $handler) {
    17.   if ($handler[4] != 1 and array_key_exists(2, $this->xmlobj) and $this->xmlobj[2]->hasSub($handler[0])) {
    18.   $searchxml = $this->xmlobj[2]->sub($handler[0]);
    19.   $searchxml = $this->xmlobj[2];
    20.   if ($searchxml !== null and $searchxml->name == $handler[0] and ($searchxml->ns == $handler[1] or (!$handler[1] and $searchxml->ns == $this->default_ns))) {
    21.   if ($handler[3] === null)
    22.   $this->log->log(«Calling {$handler[2]}«, XMPPHP_Log::LEVEL_DEBUG);
    23.   $handler[3]->$handler[2]($this->xmlobj[2]);
    24.   foreach ($this->idhandlers as $id => $handler) {
    25.   if (array_key_exists(‘id’, $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs[‘id’] == $id) {
    26.   if ($handler[1] === null)
    27.   $handler[1]->$handler[0]($this->xmlobj[2]);
    28.   #id handlers are only used once
    29.  unset($this->idhandlers[$id]);
    30.   if (isset($this->xmlobj[0]) && $this->xmlobj[0] instanceof XMPPHP_XMLObj) {
    31.   $this->xmlobj[0]->subs = null;
    32.   if ($this->xml_depth == 0 and !$this->been_reset) {
    33.   if (!$this->disconnected) {
    34.   if (!$this->sent_disconnect) {
    35.   $this->send($this->stream_end);
    36.   $this->disconnected = true;
    37.   $this->sent_disconnect = true;
    38.   $this->event(‘end_stream’);

    Заранее спасибо за помощь


  5. nospiou

    С нами с:
    4 фев 2018
    Сообщения:
    3.400
    Симпатии:
    510

    1. $handler[2]->{$handler[1]}($this->xmlobj[2]);


  6. Sail

    С нами с:
    1 ноя 2016
    Сообщения:
    1.557
    Симпатии:
    352


  7. i-grek

    С нами с:
    20 июн 2019
    Сообщения:
    1
    Симпатии:
    0

    Ошибку вызывают пустые скобки [] . А так как эта конструкция часто используется для формирования числового массива в цикле, то заполняем их при помощи дополнительной переменной
    <?
    $d = 0;
    for($arResult as $item):
    $arName[$d] = $item[‘NAME’];
    $d++;
    endforeach;
    unset($d);
    ?>

Понравилась статья? Поделить с друзьями:
  • Ошибка granite 2000000 far cry 5 решение на лицензии
  • Ошибка google process gapps lenovo
  • Ошибка function ereg replace is deprecated
  • Ошибка granite 2000000 far cry 5 codex
  • Ошибка game resource path does not exist res packages