Форум программистов, компьютерный форум, киберфорум
PHP для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.54/13: Рейтинг темы: голосов - 13, средняя оценка - 4.54
0 / 0 / 0
Регистрация: 21.08.2014
Сообщений: 2

Parse error: syntax error, unexpected end of file

21.08.2014, 11:36. Показов 2805. Ответов 3
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
( ! ) Parse error: syntax error, unexpected end of file in C:\wamp\www\web_app\v8.0\checkout.php on line 249

где тут может быть ошибка? вроде все скобки на месте


PHP
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
  include_once 'includes/config.php';
 
  /******************************************
   * Process GET variables
   **************************************************/
 
   /**
    * ADDED  V8.1 added a GET parameter to define the action
    * checkout.php should take
    */
   $action = isset($_GET['action']) ? $_GET['action'] : NULL;
 
   /**-----------------------------------------
    * Process GET vars for action='checkout'
    *----------------------------------------------*/
  /**
   * UPDATED V7.0: Create 'short forms' of GET variables
   *
   * Set short vars equal to NULL if they weren't set
   */
  $cart_items = isset($_GET['items_shopped']) ? $_GET['items_shopped'] : NULL;
 
  /*---------------------------------------------------
   * Process GET vars for cation='completeOrder'
   *-------------------------------------------------*/
 
  $cust_data   =  isset($_GET['customer']) ? $_GET['customer'] :  NULL;
  $order_total =  isset($_GET['order_total']) ? $_GET['order_total'] : NULL;
  /*********************************************************************
   * Perform any 'global' data processing
   *********************************************************************/
 
   //ADDED V8.0 booleab 'flag' to represent id error has occured
   $error = FALSE;
 
   //ADDED V8.0 Variable to hold custom error message
   $error_msg = '';
 
  if ($action == 'checkout'){
 
    if($cart_items != NULL) {
 
    /**
     * ADDED V8.0 perform input validation. Make sure at least onr
     * item has quantity >0
     */
     if (($cart_items['1001'] >0) or ($cart_items['2001'] > 0) or ($cart_items['3001'] > 0)) {
 
        /**
         * Calculate the shopping cart total by looking up the price
         * of each item in the item catalog and multiplying each item's
         * price by the quantity selected.
         *
         * The total is stored in the variable $curr_total, which will
         * be available for output in the page.
         */
 
        $curr_sub_total = 0.0 + ($item_catalog['1001']['price'] * $cart_items['1001'])
                              + ($item_catalog['2001']['price'] * $cart_items['2001'])
                              + ($item_catalog['3001']['price'] * $cart_items['3001']);
 
        $curr_total = $curr_sub_total + ($curr_sub_total * SALES_TAX_RATE);
        $curr_total = round($curr_total, 2);
 
        //define title for HTML <title> tag. Must be declared before HTML header is included
        $page_title = 'Checkout';
      }
      else {
        $error = TRUE;
 
        $error_msg = '<p> You must add at least one item to your' .
                  'cart before you can checkout.</p>';
        }
      }
    else {
      $error = TRUE;
    }
  }
  elseif ($action = 'comlete_order') {
    if (($cust_data != NULL) && ($order_total != NULL )) {
        if (!empty($cust_data['first_name']) && !empty($cust_data['last_name'])
            && !empty($cust_data['street']) && !empty($cust_data['city'])
            && !empty($cust_data['state']) && !empty($cust_data['zip'])) {
 
            //daefine title for the HTML <title> tag
            $page_title = 'Thenk You!';
        }
        else {
          $error  = TRUE;
 
          $error_msg  = '<p> You did not provide all of the necessary billing/shipping information.</p>';
 
        }
    }
    else{
        $error = TRUE;
    }
 
  }
  else {
    $error = TRUE;
    $page_title - 'Error';
    if ($error_msg == '') {
      $error_msg = '<p>You have reaxhed this page in error.</p>';
    }
  }
 
  /*************************************************************
   * Output HTML
   *************************************************************/
 
    //Include HTMLheader file
    include HTML_HEADER;
 
  if (!$error) {
    if ($action == 'checkout'){
?>
 
    <div class="title">Checkout</div>
 
    <!-- Output a message stating the cart's calculated total -->
    <p>
        Your shopping cart total is
        <b>$<?php echo $curr_total; ?></b>
         including taxes.
    </p>
 
    <p>
        Please enter your billing/shipping information to complete your order
    </p>
 
    <!--
        Create a form where a customer can enter their shipping/billing
        adress information
 
        Note: text input elements will be adding data to an associative array
        named 'customer' upon submission. This array will be accessible in thankyou.php
        via the $_GET array.
    -->
    <form action="checkout.php" method="get">
        <table id="shipping_table">
        <tr>
            <td>First Name:</td>
            <td><input type="text" name="customer[first_name]"  size="15" /></td>
        </tr>
        <tr>
            <td>Last Name:</td>
            <td><input type="text" name="customer[last_name]" size="15" /></td>
        </tr>
        <tr>
            <td>Street:</td>
            <td><input type="text" name="customer[st]"</td>
        </tr>
        <tr>
            <td>Apt. #:</td>
            <td><input type="text" name="customer[apt]" size="25" /></td>
        </tr>
        <tr>
            <td>City:</td>
            <td><input type="text" name="customer[city]" size="15" /></td>
        </tr>
        <tr>
            <td>State:</td>
            <td><input type="text" name="customer[state]" size="2" /></td>
        </tr>
        <tr>
            <td>Zip Code:</td>
            <td><input type="text" name="customer[zip]" size="10" /></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="hidden" name="action" value="complete_order"/>
                <input type="submit" value="Complete order."/>
            </td>
        </tr>
        </table>
 
        <!-- Addition of ahidden fiekd used ti 'forward' the
            claculated total on to the thank you page. -->
        <input type="hidden" name="order_total" value="<?php echo $curr_total;  ?>"/>
    </form>
 
<?php
    }
    elseif ($action = 'complete_order'){
 ?>
    <div class="title">
        Thank you!
    </div>
 
    <!-- output a message stating the customer's order total -->
 
    <p>
        Your order was completed on
 
        <!-- UODATED V6.2: added output of order creation date and time -->
        <?php echo '<em>' . date(ORDER_DATE_FORMAT) . '</em>'; ?>
 
        with a final total of
        <b>$<?php echo $order_total; ?></b> including
 
        <!-- UPDATED V6.2 added  message about sales tax rate -->
        <?php echo (SALES_TAX_RATE * 100) . '% '; ?> sales tax.
 
        It will be shipped to:
    </p>
 
    <!-- Output the billing/shipping information provided by the customer.
 
        Note: Curly brace, or 'complex', syntax is used within
        the double-quoted strings below in order to output
        associativaarray values
    -->
    <table id="thank_you_table">
    <tr>
        <td>
            <?php echo "{$cust_data['first_name']} {$cust_data['last_name']}"; ?>
        </td>
    </tr>
    <tr>
        <td>
            <?php echo "{$cust_data['st']}"; ?>
        </td>
    </tr>
    <tr>
        <td>
            Apt. #<?php echo "{$cust_data['apt']}"; ?>
        </td>
    </tr>
    <tr>
        <td>
            <?php
            //UPDATED V6.2: assures state abbreviation gets output capitalized
             echo "{$cust_data['city']}, "
                .  strtoupper($cust_data['state'])
                . " {$cust_data['zip']}"; ?>
        </td>
    </tr>
    </table>
<?php
    }
    else{
      echo $error_msg;
    }
    include HTML_FOOTER;
?>
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
21.08.2014, 11:36
Ответы с готовыми решениями:

Parse error: syntax error, unexpected end of file, expecting function (T_FUNCTION)
Выскакивает такая ошибка &quot;Parse error: syntax error, unexpected end of file, expecting function (T_FUNCTION) in...

Parse error: syntax error, unexpected end of file
Я начинаю дуреть... написал простецкий сайтик, запускаю его через WampServer, и он выдаёт вот что: Parse error: syntax error,...

Parse error: syntax error, unexpected end of file
Всем привет. Ребят подскажите пожалуйста,что здесь не так,я уже голову сломал &lt;html&gt; &lt;head&gt; Вертолеты россии...

3
1 / 1 / 0
Регистрация: 12.06.2013
Сообщений: 30
21.08.2014, 11:41
попробуй формат файла переделать в utf-8 без BOM
0
 Аватар для V@D!k
249 / 249 / 98
Регистрация: 26.07.2010
Сообщений: 1,685
21.08.2014, 12:06
у вас файл сохранен в формате php или html?

Добавлено через 3 минуты
и вообще бредовый стиль кода... как его отлаживать если вы выносите закрывающиеся скобки не пойми куда. У меня ide показывает, что не хватает одной закрывающейся скобки, но где ее поставить я вам не подскажу
0
0 / 0 / 0
Регистрация: 21.08.2014
Сообщений: 2
21.08.2014, 14:14  [ТС]
заработало, не хватало скобки в самом конце перед else
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
21.08.2014, 14:14
Помогаю со студенческими работами здесь

Выдаёт ошибку Parse error: syntax error, unexpected end of file in C:\OpenServer\domains\test.ru\index.php on
&lt;?php require &quot;bd.php&quot;; ?&gt; &lt;?php $data=$_SESSION; if(isset($_GET)) {$rol = $_GET; $querys = mysqli_query(&quot;SELECT * FROM...

Ошибка в форме обратной связи: Parse error: syntax error, unexpected $end
Всем здрасте! сделал форму обратной связь: &lt;form action=&quot;fbsend.php&quot; method=&quot;post&quot;&gt; &lt;div id=&quot;fb&quot;&gt; &lt;label&gt;Ваше имя&lt;b...

Parse error: syntax error, unexpected $end in C:\Polygone\sqltest.php on line 85.
Недавно встал на тропу работы с php и mysql. Во время набора одной из учебных программ столкнулся с ошибкой Parse error: syntax error,...

Ошибка - Parse error: syntax error, unexpected $end
всем привет. код выдает данную ошибку Parse error: syntax error, unexpected $end in Z:\home\uslugi\www\include\ajax.base.php on line...

Ошибка - Parse error: syntax error, unexpected $end
При нажатии на ссылку выдает ошибку syntax error, unexpected $end line ....(последняя строчка , m.e &lt;/html&gt;) Несколько раз...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
Новые блоги и статьи
PhpStorm 2025.3: WSL Terminal всегда стартует в ~
and_y87 14.12.2025
PhpStorm 2025. 3: WSL Terminal всегда стартует в ~ (home), игнорируя директорию проекта Симптом: После обновления до PhpStorm 2025. 3 встроенный терминал WSL открывается в домашней директории. . .
Как объединить две одинаковые БД Access с разными данными
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
Ломающие изменения в C#.NStar Alpha
Etyuhibosecyu 20.11.2025
Уже можно не только тестировать, но и пользоваться C#. NStar - писать оконные приложения, содержащие надписи, кнопки, текстовые поля и даже изображения, например, моя игра "Три в ряд" написана на этом. . .
Мысли в слух
kumehtar 18.11.2025
Кстати, совсем недавно имел разговор на тему медитаций с людьми. И обнаружил, что они вообще не понимают что такое медитация и зачем она нужна. Самые базовые вещи. Для них это - когда просто люди. . .
Создание Single Page Application на фреймах
krapotkin 16.11.2025
Статья исключительно для начинающих. Подходы оригинальностью не блещут. В век Веб все очень привыкли к дизайну Single-Page-Application . Быстренько разберем подход "на фреймах". Мы делаем одну. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru