質問編集履歴

3

update.phpのコード追加しました。

2018/02/14 09:28

投稿

SatoshiSugiyama
SatoshiSugiyama

スコア14

test CHANGED
File without changes
test CHANGED
@@ -179,3 +179,97 @@
179
179
  </html>
180
180
 
181
181
  ```
182
+
183
+
184
+
185
+
186
+
187
+ 以下が、update.phpのコードです。
188
+
189
+
190
+
191
+ ```
192
+
193
+ <?php
194
+
195
+
196
+
197
+ //以下、関数を利用する宣言 include~
198
+
199
+ include("functions.php");
200
+
201
+
202
+
203
+ //1.POSTでParamを取得
204
+
205
+ $id = $_POST["id"];
206
+
207
+ $name = $_POST["name"];
208
+
209
+ $email = $_POST["email"];
210
+
211
+ $lid = $_POST["lid"];
212
+
213
+ $lpw = $_POST["lpw"];
214
+
215
+
216
+
217
+ //2. DB接続します(エラー処理追加)
218
+
219
+ $pdo = db_con();
220
+
221
+
222
+
223
+ //以下が関数の中身:
224
+
225
+ //try {
226
+
227
+ // $pdo = new PDO('mysql:dbname=gs_db;charset=utf8;host=localhost','root','');
228
+
229
+ //} catch (PDOException $e) {
230
+
231
+ // exit('DbConnectError:'.$e->getMessage());
232
+
233
+ //}
234
+
235
+
236
+
237
+ //3.UPDATE gs_user_table SET ....; で更新(bindValue)
238
+
239
+ //基本的にinsert.phpの処理の流れです。
240
+
241
+ $stmt = $pdo->prepare("UPDATE gs_user_table name=:name, email=:email, lid=:lid, lpw=:lpw WHERE id=:id");
242
+
243
+ $stmt->bindValue(':id', $id, PDO::PARAM_INT);//一度vindValueに入れてから上のprepareに代入
244
+
245
+ $stmt->bindValue(':name', $name, PDO::PARAM_STR);
246
+
247
+ $stmt->bindValue(':email', $email, PDO::PARAM_STR);
248
+
249
+ $stmt->bindValue(':lid', $lid, PDO::PARAM_STR);
250
+
251
+ $stmt->bindValue(':lpw', $lpw, PDO::PARAM_STR);
252
+
253
+ //$stmt->bindValue(':id', $id, PDO::PARAM_INT);
254
+
255
+ $status = $stmt->execute();//実行
256
+
257
+
258
+
259
+ if($status==false){
260
+
261
+ queryError($stmt);
262
+
263
+ }else{
264
+
265
+ header("Location: select.php");//select.phpへ
266
+
267
+ exit;
268
+
269
+ }
270
+
271
+
272
+
273
+ ?>
274
+
275
+ ```

2

プログラムコード(およびエラーメッセージ)を```で囲いました

2018/02/14 09:28

投稿

SatoshiSugiyama
SatoshiSugiyama

スコア14

test CHANGED
File without changes
test CHANGED
File without changes

1

コードとエラーメッセージを ```で囲いました。

2018/02/14 01:13

投稿

SatoshiSugiyama
SatoshiSugiyama

スコア14

test CHANGED
File without changes
test CHANGED
@@ -6,13 +6,17 @@
6
6
 
7
7
  エラーメッセージ:
8
8
 
9
+ ```
10
+
9
11
  QueryError:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='uuu', email='uuu', lid='uuu', lpw='uuu' WHERE id='38'' at line 1
12
+
13
+ ```
10
14
 
11
15
 
12
16
 
13
17
  該当のソースコード:
14
18
 
15
-
19
+ ```
16
20
 
17
21
  <?php
18
22
 
@@ -173,3 +177,5 @@
173
177
  </body>
174
178
 
175
179
  </html>
180
+
181
+ ```