質問編集履歴
6
改善
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
5
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
下記エラーはecho $comment~の行を指しています
|
6
6
|
|
7
|
-
Notice: Undefined variable: time in C:\XAMPP\htdocs\
|
7
|
+
Notice: Undefined variable: time in C:\XAMPP\htdocs\XXX.php on line 21
|
8
8
|
|
9
9
|
array(2) {
|
10
10
|
|
4
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,9 +2,25 @@
|
|
2
2
|
|
3
3
|
PHPコードの中にHTMLコードを入れたいんですが、<DOCUMENT HTML>を挿入する方法は合っているのでしょうか
|
4
4
|
|
5
|
-
下記エラーは
|
5
|
+
下記エラーはecho $comment~の行を指しています
|
6
6
|
|
7
|
-
|
7
|
+
Notice: Undefined variable: time in C:\XAMPP\htdocs\mudai1.php on line 21
|
8
|
+
|
9
|
+
array(2) {
|
10
|
+
|
11
|
+
["name"]=>
|
12
|
+
|
13
|
+
string(6) "あい"
|
14
|
+
|
15
|
+
["comment"]=>
|
16
|
+
|
17
|
+
string(9) "うえお"
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
8
24
|
|
9
25
|
```PHP
|
10
26
|
|
@@ -16,6 +32,24 @@
|
|
16
32
|
|
17
33
|
<html>
|
18
34
|
|
35
|
+
<DOCMENT HTML>
|
36
|
+
|
37
|
+
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head>
|
38
|
+
|
39
|
+
<body>
|
40
|
+
|
41
|
+
<form method="post" action="XXX.php">
|
42
|
+
|
43
|
+
名前:<input type="text" name="name">
|
44
|
+
|
45
|
+
内容:<textarea name="comment" row="20" cols="20"> </textarea>
|
46
|
+
|
47
|
+
<input type="submit" value="投稿">
|
48
|
+
|
49
|
+
</form>
|
50
|
+
|
51
|
+
</body>
|
52
|
+
|
19
53
|
<body>
|
20
54
|
|
21
55
|
<?php
|
@@ -24,15 +58,13 @@
|
|
24
58
|
|
25
59
|
$comment = $_POST['comment'];
|
26
60
|
|
27
|
-
$name = htmlspecialchars($name, ENT_QUOTES, '
|
61
|
+
$name = htmlspecialchars($name, ENT_QUOTES, 'utf-8');
|
28
62
|
|
29
|
-
$comment = htmlspecialchars($comment, ENT_QUOTES, '
|
63
|
+
$comment = htmlspecialchars($comment, ENT_QUOTES, 'utf-8');
|
30
64
|
|
31
|
-
echo
|
65
|
+
echo $name, '<br>', PHP_EOL;
|
32
66
|
|
33
|
-
echo
|
67
|
+
echo $comment, $time, PHP_EOL;
|
34
|
-
|
35
|
-
echo '', $time, '', PHP_EOL;
|
36
68
|
|
37
69
|
|
38
70
|
|
@@ -106,24 +138,6 @@
|
|
106
138
|
|
107
139
|
|
108
140
|
|
109
|
-
<DOCMENT HTML>
|
110
|
-
|
111
|
-
<head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head>
|
112
|
-
|
113
|
-
<body>
|
114
|
-
|
115
|
-
<form method="post" action="XXX.php">
|
116
|
-
|
117
|
-
名前:<input type="text" name="name">
|
118
|
-
|
119
|
-
内容:<textarea name="comment" row="20" cols="20"> </textarea>
|
120
|
-
|
121
|
-
<input type="submit" value="投稿">
|
122
|
-
|
123
|
-
</form>
|
124
|
-
|
125
|
-
</body>
|
126
|
-
|
127
141
|
?>
|
128
142
|
|
129
143
|
</body>
|
3
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
以下のコードを打ってみたんですが、調べても原因が把握できません
|
2
2
|
|
3
|
-
N
|
3
|
+
PHPコードの中にHTMLコードを入れたいんですが、<DOCUMENT HTML>を挿入する方法は合っているのでしょうか
|
4
4
|
|
5
|
+
下記エラーはDOCUMENT~の行を指しています
|
6
|
+
|
5
|
-
|
7
|
+
Parse error: syntax error, unexpected '<', expecting end of file in C:\XAMPP\htdocs\XXX.php on line 50
|
6
8
|
|
7
9
|
```PHP
|
8
10
|
|
@@ -30,6 +32,16 @@
|
|
30
32
|
|
31
33
|
echo '', $comment, '', PHP_EOL;
|
32
34
|
|
35
|
+
echo '', $time, '', PHP_EOL;
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
echo '<pre>';
|
40
|
+
|
41
|
+
var_dump($_POST);
|
42
|
+
|
43
|
+
echo '</pre>';
|
44
|
+
|
33
45
|
|
34
46
|
|
35
47
|
$user = 'XXX';
|
@@ -44,7 +56,7 @@
|
|
44
56
|
|
45
57
|
$mysqli = new mysqli($host, $user, $password, $dbname);
|
46
58
|
|
47
|
-
if
|
59
|
+
if($mysqli->connect_error){
|
48
60
|
|
49
61
|
print("接続失敗:" . $mysqli->connect_error);
|
50
62
|
|
@@ -58,19 +70,19 @@
|
|
58
70
|
|
59
71
|
|
60
72
|
|
61
|
-
$stm = $mysqli->prepare('INSERT INTO XXX (name, comment) VALUES (?, ?)');
|
73
|
+
$stmt = $mysqli->prepare('INSERT INTO XXX (name, comment) VALUES (?, ?)');
|
62
74
|
|
63
|
-
$stm->bind_param('ss', $_POST['name'], $_POST['comment']);
|
75
|
+
$stmt->bind_param('ss', $_POST['name'], $_POST['comment']);
|
64
76
|
|
65
|
-
$stm->execute();
|
77
|
+
$stmt->execute();
|
66
78
|
|
67
79
|
|
68
80
|
|
69
81
|
$query = 'SELECT * FROM XXX';
|
70
82
|
|
71
|
-
$stm = $mysqli->prepare($
|
83
|
+
$stmt = $mysqli->prepare($query);
|
72
84
|
|
73
|
-
$stm->execute();
|
85
|
+
$stmt->execute();
|
74
86
|
|
75
87
|
|
76
88
|
|
@@ -94,6 +106,24 @@
|
|
94
106
|
|
95
107
|
|
96
108
|
|
109
|
+
<DOCMENT HTML>
|
110
|
+
|
111
|
+
<head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head>
|
112
|
+
|
113
|
+
<body>
|
114
|
+
|
115
|
+
<form method="post" action="XXX.php">
|
116
|
+
|
117
|
+
名前:<input type="text" name="name">
|
118
|
+
|
119
|
+
内容:<textarea name="comment" row="20" cols="20"> </textarea>
|
120
|
+
|
121
|
+
<input type="submit" value="投稿">
|
122
|
+
|
123
|
+
</form>
|
124
|
+
|
125
|
+
</body>
|
126
|
+
|
97
127
|
?>
|
98
128
|
|
99
129
|
</body>
|
2
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Notice: Undefined variable: sql in C:\XAMPP\htdocs\XXX.php on line 32
|
4
4
|
|
5
|
-
Fatal error: Uncaught Error: Call to a member function execute() on boolean in C:\XAMPP\htdocs\
|
5
|
+
Fatal error: Uncaught Error: Call to a member function execute() on boolean in C:\XAMPP\htdocs\XXX.php:33 Stack trace: #0 {main} thrown in C:\XAMPP\htdocs\XXX.php on line 33
|
6
6
|
|
7
7
|
```PHP
|
8
8
|
|
1
改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
以下のコードを打ってみたんですが、
|
1
|
+
以下のコードを打ってみたんですが、調べても原因が把握できません
|
2
2
|
|
3
|
-
|
3
|
+
Notice: Undefined variable: sql in C:\XAMPP\htdocs\XXX.php on line 32
|
4
4
|
|
5
|
-
|
5
|
+
Fatal error: Uncaught Error: Call to a member function execute() on boolean in C:\XAMPP\htdocs\mudai1.php:33 Stack trace: #0 {main} thrown in C:\XAMPP\htdocs\XXX.php on line 33
|
6
6
|
|
7
7
|
```PHP
|
8
8
|
|
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
$time = date("y/m/d h:i:s")
|
57
|
+
$time = date("y/m/d h:i:s");
|
58
58
|
|
59
59
|
|
60
60
|
|