質問編集履歴
1
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
php
|
1
|
+
phpにかんしてです
|
test
CHANGED
@@ -1,185 +1 @@
|
|
1
|
-
http://log.digicafe.jp/program/sample/sample.php
|
2
|
-
|
3
|
-
以前phpにてタイトルと本文記入し、
|
4
|
-
|
5
|
-
保存ボタン押した後に内容をファイルに保存をして行くのを作ってみたのですが
|
6
|
-
|
7
|
-
〈 タイトル 本文 書き込み日時〉
|
8
|
-
|
9
|
-
〈タイトル 本文 書き込み日時〉
|
10
|
-
|
11
|
-
みたいに保存されてしく形です
|
12
|
-
|
13
|
-
これをDBに追加したいのですがエラーコードが出てしまいます。 書いた文を載せております。根本的に文が違ったりしたらアドバイスお願いします間違いだらけかと思いますすいません
|
14
|
-
|
15
|
-
<?php
|
16
|
-
|
17
|
-
session_start();
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@$title="掲示板サンプル";
|
22
|
-
|
23
|
-
@$url="homepage/test6.php";
|
24
|
-
|
25
|
-
list($urlbe,$urlaf)=explode("/",$url,2);
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
mysql_connect('localhost','ogawa','taku1106') or die(mysql_error());
|
30
|
-
|
31
|
-
mysql_select_db('ogawa');
|
32
|
-
|
33
|
-
mysql_query('set names utf8');
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
function newstring($string) {
|
38
|
-
|
39
|
-
if(get_magic_quotes_gpc()) {
|
40
|
-
|
41
|
-
$string = stripslashes($string);
|
42
|
-
|
43
|
-
}
|
44
|
-
|
45
|
-
$string = htmlspecialchars($string,ENT_QUOTES,'utf-8');
|
46
|
-
|
47
|
-
$string = str_replace(",",",",$string);
|
48
|
-
|
49
|
-
$string = str_replace(array("\r\n","\n","\r"),"<br>",$string);
|
50
|
-
|
51
|
-
return $string;
|
52
|
-
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
$save_dir="../../file/img/";
|
58
|
-
|
59
|
-
$filemei=newstring(@$_FILES["upfile"]["name"]);
|
60
|
-
|
61
|
-
$filetmp=newstring(@$_FILES["upfile"]["tmp_name"]);
|
62
|
-
|
63
|
-
$file_check=substr($filemei,-3);
|
64
|
-
|
65
|
-
if($file_check==("jpg"||"JPG"||"jpeg"||"png"||"gif"||"bmp")) {
|
66
|
-
|
67
|
-
$file_name=$save_dir.$filemei;
|
68
|
-
|
69
|
-
if (is_uploaded_file($filetmp)) {
|
70
|
-
|
71
|
-
move_uploaded_file($filetmp,$file_name);
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
$sql = sprintf("INSERT INTO test set name='%s',sub='%s',body='%s',title='%s',url='%s',img='%s',created=NOW()",
|
80
|
-
|
81
|
-
mysql_real_escape_string($_SESSION['join']['name']),
|
82
|
-
|
83
|
-
mysql_real_escape_string($_SESSION['join']['sub']),
|
84
|
-
|
85
|
-
mysql_real_escape_string($_SESSION['join']['body']),
|
86
|
-
|
87
|
-
$title,$url,
|
88
|
-
|
89
|
-
mysql_real_escape_string($_FILES["upfile"]["name"])
|
90
|
-
|
91
|
-
);
|
92
|
-
|
93
|
-
mysql_query($sql) or die(mysql_error());
|
94
|
-
|
95
|
-
?>
|
96
|
-
|
97
|
-
<html>
|
98
|
-
|
99
|
-
<head>
|
100
|
-
|
101
|
-
<meta http-equiv="content-type" content="text/html;charset=UTF8;" />
|
102
|
-
|
103
|
-
<table border="1">
|
104
|
-
|
105
|
-
<form action="for3.php" method="POST">
|
106
|
-
|
107
|
-
<tr><th>タイトル<td><input type="text" name="text" size="50"></td></tr>
|
108
|
-
|
109
|
-
<tr><th>本文<td><textarea name="subject" cols="52" rows="8"></textarea>
|
110
|
-
|
111
|
-
<tr><td><input type="submit" value="保存 する" /></td><tr>
|
112
|
-
|
113
|
-
</table>
|
114
|
-
|
115
|
-
</form>
|
116
|
-
|
117
|
-
<strong style="color:#e01;">タイトルと本文を入力してください</strong><br />
|
118
|
-
|
119
|
-
<?php
|
120
|
-
|
121
|
-
$data = mysql_query("SELECT COUNT(*) AS cnt FROM test k where k.url='".$url."'") or die(mysql_error());
|
122
|
-
|
123
|
-
$kensu = mysql_fetch_assoc($data);
|
124
|
-
|
125
|
-
if(empty($page)) {
|
126
|
-
|
127
|
-
$page=1;
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
if(!empty($_REQUEST['page'])) {
|
132
|
-
|
133
|
-
$page=$_REQUEST['page'];
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
if($kensu['cnt']<1) {
|
138
|
-
|
139
|
-
$kensu['cnt']=1;
|
140
|
-
|
141
|
-
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
$recordSet = mysql_query("SELECT * FROM test k where k.url='".$url."' ORDER BY k.id DESC LIMIT ".$start.",10") or die(mysql_error());
|
146
|
-
|
147
|
-
|
1
|
+
どのようにプルダウン式で選択後送信したらはんえいできます?詳しいサイトなどありますか?
|
148
|
-
|
149
|
-
echo("<p class='p2'>No".newstring($datas['id'])." タイトル:".newstring($datas['sub'])." 本文:".newstring($datas['name'])." 投稿日:".newstring($datas['created']).
|
150
|
-
|
151
|
-
"</p><p class='p3'>".newstring($datas['body'])."</p>");
|
152
|
-
|
153
|
-
if(!empty($datas['img'])){
|
154
|
-
|
155
|
-
echo("<figure class='p4'><img src='http://localhost/img/".newstring($datas['img'])."' alt='' /></figure>");
|
156
|
-
|
157
|
-
}else{
|
158
|
-
|
159
|
-
echo("<hr />");
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
?>
|
166
|
-
|
167
|
-
DB側のテーブル構造
|
168
|
-
|
169
|
-
id int
|
170
|
-
|
171
|
-
sub varchar
|
172
|
-
|
173
|
-
name varchar
|
174
|
-
|
175
|
-
body text
|
176
|
-
|
177
|
-
created datetime
|
178
|
-
|
179
|
-
modified timestanp
|
180
|
-
|
181
|
-
title varchar
|
182
|
-
|
183
|
-
url varchar
|
184
|
-
|
185
|
-
img varchar
|