質問編集履歴

3

情報の補足

2021/01/05 05:29

投稿

kotouharuto
kotouharuto

スコア38

test CHANGED
File without changes
test CHANGED
@@ -108,6 +108,80 @@
108
108
 
109
109
 
110
110
 
111
+
112
+
113
+ # 補足情報
114
+
115
+ エラーログに記載していたweight_chart.phpです
116
+
117
+ ```php
118
+
119
+ <?php
120
+
121
+ include('../libs/init.php');
122
+
123
+
124
+
125
+ // ログインしていなかったらログインしてもらう
126
+
127
+ if(!isset($_SESSION['user_id'])) {
128
+
129
+ header("Location: login.php");
130
+
131
+ exit();
132
+
133
+ }
134
+
135
+
136
+
137
+ // DB接続
138
+
139
+ $pdo = db_connect();
140
+
141
+ $pdo->beginTransaction();
142
+
143
+
144
+
145
+ // 空の変数$date, $weightを用意(DBのデータを表示するために)
146
+
147
+ $user_id = '';
148
+
149
+ $date = '';
150
+
151
+ $weight = '';
152
+
153
+ $stmt = '';
154
+
155
+
156
+
157
+ $stmt = fetchAllWeight($pdo, $_SESSION['user_id']);
158
+
159
+
160
+
161
+ $date = trim($date, ",");
162
+
163
+ $weight = trim($weight, ",");
164
+
165
+
166
+
167
+ // Smarty接続
168
+
169
+ $smarty = getSmarty();
170
+
171
+ $smarty->assign('USERNAME', $_SESSION['USERNAME']);
172
+
173
+ $smarty->assign('date', $date);
174
+
175
+ $smarty->assign('weight', $weight);
176
+
177
+ $smarty->display('weight_chart.tpl');
178
+
179
+ ?>
180
+
181
+ ```
182
+
183
+
184
+
111
185
  ---
112
186
 
113
187
 

2

情報の補足

2021/01/05 05:28

投稿

kotouharuto
kotouharuto

スコア38

test CHANGED
File without changes
test CHANGED
@@ -40,6 +40,50 @@
40
40
 
41
41
 
42
42
 
43
+ ---
44
+
45
+ Applications/MAMP/logs/php_error.logで確認したエラー内容です
46
+
47
+ ```
48
+
49
+ PHP Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/Original-Application/main/app/weight_chart.php:9) in /Applications/MAMP/htdocs/Original-Application/main/libs/function.php on line 78
50
+
51
+ ```
52
+
53
+ スクリプトの実行中にheader()をしたことで発生するエラーのようです
54
+
55
+
56
+
57
+ ちなみにエラーで指摘されている箇所はこうなっています
58
+
59
+ ```
60
+
61
+ function INSERT2($pdo, $user_id, $date, $weight) {
62
+
63
+ $sql = "INSERT INTO chart(user_id, date, weight) VALUES (:user_id, :date, :weight)";
64
+
65
+ $stmt = $pdo->prepare($sql);
66
+
67
+ $stmt->bindValue(':user_id', $_SESSION['user_id'], PDO::PARAM_STR);
68
+
69
+ $stmt->bindValue(':date', $date, PDO::PARAM_STR);
70
+
71
+ $stmt->bindValue(':weight', $weight, PDO::PARAM_STR);
72
+
73
+ $stmt->execute();
74
+
75
+ $pdo->commit();
76
+
77
+ // header("Location:weight_chart.php"); おそらくここがエラーになっているようです
78
+
79
+ // exit();
80
+
81
+ }
82
+
83
+ ```
84
+
85
+
86
+
43
87
  # 試したこと
44
88
 
45
89
  - FileZillaで必要なファイルを全て再アップロードをやってみたのですが、結局何も変わりませんでした。

1

タグの修正

2021/01/04 14:01

投稿

kotouharuto
kotouharuto

スコア38

test CHANGED
File without changes
test CHANGED
File without changes