質問編集履歴

1

プログラムとエラーメッセージを更新しました。

2021/01/05 09:07

投稿

noizi.
noizi.

スコア27

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ```
14
14
 
15
- Error:SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '"111111' at line 1
15
+ Error:SQLSTATE[42S22]: Column not found: 1054 Unknown column 'C_num' in 'where clause'
16
16
 
17
17
  ```
18
18
 
@@ -36,11 +36,13 @@
36
36
 
37
37
  $dbh = new PDO($dsn, $user, $password);
38
38
 
39
- $C_nam = "山田 太郎";
39
+ $C_nam = "C_name";
40
40
 
41
- $C_nm = 111111;
41
+ $C_nm = "C_num";
42
42
 
43
- $sql = 'select * from example where C_nam ='.$C_nam.' and C_nm="'.$C_nm.'';
43
+ $sql = 'select * from example where C_nam = "'.$C_nam.'" and C_nm= '.$C_nm.'';
44
+
45
+ //$sql = 'select * from example where C_nam = "山田 太郎" and C_nm= "111111"';
44
46
 
45
47
 
46
48
 
@@ -130,7 +132,11 @@
130
132
 
131
133
  <div class="control">
132
134
 
135
+ <form action="c_search.php" method="GET">
136
+
133
- <button type="submit">検索</button>
137
+ <input type="submit" value="検索">
138
+
139
+ </for>
134
140
 
135
141
  <form action="menu.php" method="GET">
136
142
 
@@ -155,3 +161,5 @@
155
161
 
156
162
 
157
163
  データベースのカラム名変更
164
+
165
+ $sqlの部分を変更