質問編集履歴

1

submit\.phpの変更

2015/11/09 22:35

投稿

hakutou5963
hakutou5963

スコア15

test CHANGED
File without changes
test CHANGED
@@ -46,6 +46,22 @@
46
46
 
47
47
  ```ここに言語を入力
48
48
 
49
+ ini_set('display_errors', 1);
50
+
51
+ error_reporting(E_ALL);
52
+
53
+
54
+
55
+ // 初期化
56
+
57
+ $error = null;
58
+
59
+ $msg = null;
60
+
61
+ $processgif = null;
62
+
63
+
64
+
49
65
  if($_REQUEST['subimage']!="")
50
66
 
51
67
  {
@@ -58,13 +74,13 @@
58
74
 
59
75
  $scriptolutiondesc = cleanit($_REQUEST['scriptolutiondesc']);
60
76
 
61
- // 画像サイズ 取得を追加
77
+ // 追加
62
78
 
63
79
  $size = $_FILES['postimage']['size'];
64
80
 
65
81
 
66
82
 
67
- // 画像大きさ取得を追加
83
+ // 画像サイズを取得
68
84
 
69
85
  list($width, $height) = getimagesize($uploadedimage);
70
86
 
@@ -106,23 +122,37 @@
106
122
 
107
123
  {
108
124
 
109
- if($scriptolutiondesc != "")
110
-
111
- {
112
-
113
- $addme = ", scriptolutiondesc='".mysql_real_escape_string($scriptolutiondesc)."'";
114
-
115
- }
116
-
117
-
118
-
119
- // 追加
120
-
121
- $query="INSERT INTO posts SET active='0', time_added='".time()."', date_added='".date("Y-m-d")."', ip='".$_SERVER['REMOTE_ADDR']."', size='".$size."', width='".$width."', height='".$height."', $addme";
122
-
123
-
124
-
125
- $result=$conn->execute($query);
125
+
126
+
127
+ $record_datum = array(
128
+
129
+ 'active' => "'".'0'."'",
130
+
131
+ 'time_added' => "'".time()."'",
132
+
133
+ 'date_added' => "'".date("Y-m-d")."'",
134
+
135
+ 'ip' => "'".$_SERVER['REMOTE_ADDR']."'",
136
+
137
+ 'size' => $size,
138
+
139
+ 'width' => $width,
140
+
141
+ 'height' => $height,
142
+
143
+ );
144
+
145
+ if ($scriptolutiondesc != "")
146
+
147
+ {
148
+
149
+ $record_datum['scriptolutiondesc'] = "'".mysql_real_escape_string($scriptolutiondesc)."'";
150
+
151
+ }
152
+
153
+ $query = sprintf("INSERT INTO posts (%s) VALUES (%s);", array_keys($record_datum), array_values($record_datum));
154
+
155
+ $result=$conn->execute($query);
126
156
 
127
157
  $id = mysql_insert_id();
128
158
 
@@ -426,8 +456,24 @@
426
456
 
427
457
  ```
428
458
 
459
+ miyabi-sun様とKosuke_Shibuya様のアドバイスを元に上記のように変更してみました。
460
+
461
+ ```ここに言語を入力
462
+
463
+ ini_set('display_errors', 1);
464
+
465
+ error_reporting(E_ALL);
466
+
467
+ ```
468
+
469
+ 上記を追加したことで複数「Notice: Undefined variable」が表示されたので5行目~7行目で変数の初期化を追加しました。
470
+
429
- 上記で取得・保存できると教えて頂いたのですが上記の内容だとMysqlに何も保存されなくなってしいます私の設定が悪いのか教えて頂い内容間違っているのか分からず困っています。(エラー表示無し
471
+ エラーも無くなったので、画像投稿を行ってもMysqlデータは保存されません(投稿も政情に完了しとメッセージ・・・
430
-
431
-
432
-
472
+
433
- 詳しい方折られましたらアドバイスを頂けないでしょうか?うかよろしくお願いします
473
+ これは、PHP側でしょうか?それともMySQL側の設定が悪いのでしょうか
474
+
475
+
476
+
477
+ PHP5.2.8
478
+
479
+ MySQL5.1.30