質問編集履歴
2
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -62,6 +62,8 @@
|
|
62
62
|
|
63
63
|
localhostは実機では正しいアドレスを記入しています
|
64
64
|
|
65
|
+
```c#
|
66
|
+
|
65
67
|
using System.Collections;
|
66
68
|
|
67
69
|
using System.Collections.Generic;
|
@@ -232,10 +234,14 @@
|
|
232
234
|
|
233
235
|
|
234
236
|
|
237
|
+
```
|
238
|
+
|
235
239
|
|
236
240
|
|
237
241
|
Unityからデータを受け取るphp
|
238
242
|
|
243
|
+
```php
|
244
|
+
|
239
245
|
<?php
|
240
246
|
|
241
247
|
require "API_prd_cp.php";
|
@@ -272,12 +278,16 @@
|
|
272
278
|
|
273
279
|
?>
|
274
280
|
|
281
|
+
```
|
282
|
+
|
275
283
|
|
276
284
|
|
277
285
|
phpからphpにデータを受け取りデータを返すphp
|
278
286
|
|
279
287
|
hostやパスにはphpmyadminにログインした時のものを使っております
|
280
288
|
|
289
|
+
```php
|
290
|
+
|
281
291
|
function main($name,$name2,$hol){
|
282
292
|
|
283
293
|
try{
|
@@ -541,3 +551,5 @@
|
|
541
551
|
}
|
542
552
|
|
543
553
|
}
|
554
|
+
|
555
|
+
```
|
1
該当コードの記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,3 +47,497 @@
|
|
47
47
|
|
48
48
|
|
49
49
|
全く間違いと思われる部分に心当たりがないため開示すべき情報についてもどうかご教授お願いします。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
追記1
|
54
|
+
|
55
|
+
以下に該当の見ていただきたいコードを載せます。
|
56
|
+
|
57
|
+
ただパスワードなどは*で隠しております。ご了承ください。
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
送受信する側のUNITYC#ファイル
|
62
|
+
|
63
|
+
localhostは実機では正しいアドレスを記入しています
|
64
|
+
|
65
|
+
using System.Collections;
|
66
|
+
|
67
|
+
using System.Collections.Generic;
|
68
|
+
|
69
|
+
using UnityEngine;
|
70
|
+
|
71
|
+
using UnityEngine.UI;
|
72
|
+
|
73
|
+
using UnityEngine.Networking;
|
74
|
+
|
75
|
+
public class PHPTEST : MonoBehaviour
|
76
|
+
|
77
|
+
{
|
78
|
+
|
79
|
+
public Text ResultText_;
|
80
|
+
|
81
|
+
public GameObject Drop_1;
|
82
|
+
|
83
|
+
public GameObject Drop_2;
|
84
|
+
|
85
|
+
Dropdown_1 drop;
|
86
|
+
|
87
|
+
Dropdown_2 drop2;
|
88
|
+
|
89
|
+
private string time;
|
90
|
+
|
91
|
+
public int callory_time;
|
92
|
+
|
93
|
+
private string ServerAddress = "http://localhost/php/API_req.php";
|
94
|
+
|
95
|
+
// Use this for initialization
|
96
|
+
|
97
|
+
void Start()
|
98
|
+
|
99
|
+
{
|
100
|
+
|
101
|
+
drop = Drop_1.GetComponent<Dropdown_1>();
|
102
|
+
|
103
|
+
drop2 = Drop_2.GetComponent<Dropdown_2>();
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
public void SendSignal_Button_Push()
|
108
|
+
|
109
|
+
{
|
110
|
+
|
111
|
+
if(drop.rel==null||drop2.rel2==null){
|
112
|
+
|
113
|
+
Debug.Log("値が入力されていません");
|
114
|
+
|
115
|
+
ResultText_.GetComponent<Text>().text = "値が入力されていません";
|
116
|
+
|
117
|
+
return;
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
StartCoroutine("Access");
|
122
|
+
|
123
|
+
Debug.Log(drop.rel);
|
124
|
+
|
125
|
+
Debug.Log(drop2.rel2);
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
private IEnumerator Access()
|
132
|
+
|
133
|
+
{
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
Dictionary<string, string> dic = new Dictionary<string, string>
|
138
|
+
|
139
|
+
{
|
140
|
+
|
141
|
+
{ "id_1", drop.rel},
|
142
|
+
|
143
|
+
{ "id_2", drop2.rel2 }
|
144
|
+
|
145
|
+
};
|
146
|
+
|
147
|
+
Debug.Log(dic["id_1"]);
|
148
|
+
|
149
|
+
Debug.Log(dic["id_2"]);
|
150
|
+
|
151
|
+
StartCoroutine(Post(ServerAddress, dic));
|
152
|
+
|
153
|
+
yield return 0;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
private IEnumerator Post(string url, Dictionary<string, string> post)
|
160
|
+
|
161
|
+
{
|
162
|
+
|
163
|
+
WWWForm form = new WWWForm();
|
164
|
+
|
165
|
+
foreach (KeyValuePair<string, string> post_arg in post)
|
166
|
+
|
167
|
+
{
|
168
|
+
|
169
|
+
form.AddField(post_arg.Key, post_arg.Value);
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
UnityWebRequest www = UnityWebRequest.Post(ServerAddress,form);
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
www.timeout = 30;
|
180
|
+
|
181
|
+
yield return www.SendWebRequest();
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
if (www.error != null)
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
ResultText_.GetComponent<Text>().text = www.error;
|
190
|
+
|
191
|
+
Debug.Log("HttpPost NG:" + www.error);
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
else if (www.isDone)
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
Debug.Log(www.downloadHandler.text);
|
200
|
+
|
201
|
+
time = www.downloadHandler.text;
|
202
|
+
|
203
|
+
ResultText_.GetComponent<Text>().text =time;
|
204
|
+
|
205
|
+
callory_time = int.Parse(time);
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
www=null;
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
// Update is called once per frame
|
222
|
+
|
223
|
+
void Update()
|
224
|
+
|
225
|
+
{
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
Unityからデータを受け取るphp
|
238
|
+
|
239
|
+
<?php
|
240
|
+
|
241
|
+
require "API_prd_cp.php";
|
242
|
+
|
243
|
+
$url="http://s-proj.com/utils/checkHoliday.php?kind=h";
|
244
|
+
|
245
|
+
$holiday_check=file_get_contents($url);
|
246
|
+
|
247
|
+
$id_1=$_POST["id_1"];
|
248
|
+
|
249
|
+
$id_2=$_POST["id_2"];
|
250
|
+
|
251
|
+
$res=$id_1.$id_2;
|
252
|
+
|
253
|
+
if($holiday_check=="holiday"){
|
254
|
+
|
255
|
+
$holiday=1;
|
256
|
+
|
257
|
+
$res=main($id_1,$id_2,$holiday);
|
258
|
+
|
259
|
+
}else if($holiday_check=="else"){
|
260
|
+
|
261
|
+
$holiday=0;
|
262
|
+
|
263
|
+
$res=main($id_1,$id_2,$holiday);
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
echo $res;
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
?>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
phpからphpにデータを受け取りデータを返すphp
|
278
|
+
|
279
|
+
hostやパスにはphpmyadminにログインした時のものを使っております
|
280
|
+
|
281
|
+
function main($name,$name2,$hol){
|
282
|
+
|
283
|
+
try{
|
284
|
+
|
285
|
+
$db=new PDO('mysql:dbname=*;host=*;charset=utf8','*','*');
|
286
|
+
|
287
|
+
if($hol==1){
|
288
|
+
|
289
|
+
$result_from=$db->prepare("SELECT * FROM API_about WHERE TIME(station_time)>=NOW() AND station_name LIKE '%$name%' AND day_sp LIKE '%SaturdayHoliday%' AND looping LIKE '%Inner%' ORDER BY TIME(station_time) LIMIT 1");
|
290
|
+
|
291
|
+
$result_from2=$db->prepare("SELECT * FROM API_about WHERE TIME(station_time)>=NOW() AND station_name LIKE'%$name%' AND day_sp LIKE '%SaturdayHoliday%' AND looping LIKE '%Inner%' ORDER BY TIME(station_time) LIMIT 1");
|
292
|
+
|
293
|
+
$result_from->execute();
|
294
|
+
|
295
|
+
$result_from2->execute();
|
296
|
+
|
297
|
+
$result_from->setFetchMode(PDO::FETCH_ASSOC);
|
298
|
+
|
299
|
+
$result_from2->setFetchMode(PDO::FETCH_ASSOC);
|
300
|
+
|
301
|
+
$row_from=$result_from->fetch();
|
302
|
+
|
303
|
+
$row_from2=$result_from2->fetch();
|
304
|
+
|
305
|
+
$num=(string)$row_from['station_number'];
|
306
|
+
|
307
|
+
$num2=(string)$row_from2['station_number'];
|
308
|
+
|
309
|
+
$day=$row_from['day_sp'];
|
310
|
+
|
311
|
+
$day2=$row_from2['day_sp'];
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
$result_to=$db->prepare("SELECT*FROM API_about WHERE station_name LIKE '%$name2%' AND station_number='$num' LIMIT 1 ");
|
316
|
+
|
317
|
+
$result_to2=$db->prepare("SELECT*FROM API_about WHERE station_name LIKE '%$name2%' AND station_number='$num2' LIMIT 1 ");
|
318
|
+
|
319
|
+
$result_to->execute();
|
320
|
+
|
321
|
+
$result_to2->execute();
|
322
|
+
|
323
|
+
$result_to->setFetchMode(PDO::FETCH_ASSOC);
|
324
|
+
|
325
|
+
$result_to2->setFetchMode(PDO::FETCH_ASSOC);
|
326
|
+
|
327
|
+
$row_to=$result_to->fetch();
|
328
|
+
|
329
|
+
$row_to2=$result_to2->fetch();
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
$time_from=strtotime($row_from['station_time']);
|
334
|
+
|
335
|
+
$time_from2=strtotime($row_from2['station_time']);
|
336
|
+
|
337
|
+
$time_to=strtotime($row_to['station_time']);
|
338
|
+
|
339
|
+
$time_to2=strtotime($row_to2['station_time']);
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
if($time_from>$time_to){
|
344
|
+
|
345
|
+
$time_cal_result=$time_from-$time_to;
|
346
|
+
|
347
|
+
}else{
|
348
|
+
|
349
|
+
$time_cal_result=$time_to-$time_from;
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
if($time_from2>$time_to2){
|
354
|
+
|
355
|
+
$time_cal_result2=$time_from2-$time_to2;
|
356
|
+
|
357
|
+
}else{
|
358
|
+
|
359
|
+
$time_cal_result2=$time_to2-$time_from2;
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
if($time_cal_result==null||$time_cal_result2==null)echo "MISS4";
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
if($time_cal_result>$time_cal_result2)
|
372
|
+
|
373
|
+
{
|
374
|
+
|
375
|
+
echo date("i",$time_cal_result2);
|
376
|
+
|
377
|
+
}else{
|
378
|
+
|
379
|
+
echo date("i",$time_cal_result);
|
380
|
+
|
381
|
+
}
|
382
|
+
|
383
|
+
//echo date("i",$time_cal_result)."Inner";
|
384
|
+
|
385
|
+
//echo date("i",$time_cal_result2)."Outer";
|
386
|
+
|
387
|
+
}else if($hol==0){
|
388
|
+
|
389
|
+
$result_from=$db->prepare("SELECT * FROM API_about WHERE TIME(station_time)>=NOW() AND station_name LIKE '%$name%' AND day_sp LIKE '%SaturdayHoliday%' AND looping LIKE '%Inner%' ORDER BY TIME(station_time) LIMIT 1");
|
390
|
+
|
391
|
+
$result_from2=$db->prepare("SELECT * FROM API_about WHERE TIME(station_time)>=NOW() AND station_name LIKE'%$name%' AND day_sp LIKE '%SaturdayHoliday%' AND looping LIKE '%Outer%' ORDER BY TIME(station_time) LIMIT 1");
|
392
|
+
|
393
|
+
$result_from->execute();
|
394
|
+
|
395
|
+
$result_from2->execute();
|
396
|
+
|
397
|
+
$result_from->setFetchMode(PDO::FETCH_ASSOC);
|
398
|
+
|
399
|
+
$result_from2->setFetchMode(PDO::FETCH_ASSOC);
|
400
|
+
|
401
|
+
$row_from=$result_from->fetch();
|
402
|
+
|
403
|
+
$row_from2=$result_from2->fetch();
|
404
|
+
|
405
|
+
$num=(string)$row_from['station_number'];
|
406
|
+
|
407
|
+
$num2=(string)$row_from2['station_number'];
|
408
|
+
|
409
|
+
$day=$row_from['day_sp'];
|
410
|
+
|
411
|
+
$day2=$row_from2['day_sp'];
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
$result_to=$db->prepare("SELECT*FROM API_about WHERE station_name LIKE '%$name2%' AND station_number='$num' AND day_sp LIKE '%SaturdayHoliday%' AND looping LIKE '%Inner%' LIMIT 1 ");
|
416
|
+
|
417
|
+
$result_to2=$db->prepare("SELECT*FROM API_about WHERE station_name LIKE '%$name2%' AND station_number='$num2' AND day_sp LIKE '%SaturdayHoliday%' AND looping LIKE '%Outer%' LIMIT 1 ");
|
418
|
+
|
419
|
+
$result_to->execute();
|
420
|
+
|
421
|
+
$result_to2->execute();
|
422
|
+
|
423
|
+
$result_to->setFetchMode(PDO::FETCH_ASSOC);
|
424
|
+
|
425
|
+
$result_to2->setFetchMode(PDO::FETCH_ASSOC);
|
426
|
+
|
427
|
+
$row_to=$result_to->fetch();
|
428
|
+
|
429
|
+
$row_to2=$result_to2->fetch();
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
/*echo $row_from['station_time'];
|
434
|
+
|
435
|
+
echo "<br/>";
|
436
|
+
|
437
|
+
echo $row_from2['station_time'];
|
438
|
+
|
439
|
+
echo "<br/>";
|
440
|
+
|
441
|
+
echo $row_to['station_time'];
|
442
|
+
|
443
|
+
echo "<br/>";
|
444
|
+
|
445
|
+
echo $row_to2['station_time'];
|
446
|
+
|
447
|
+
echo "<br/>";*/
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
$time_from=strtotime($row_from['station_time']);
|
452
|
+
|
453
|
+
$time_from2=strtotime($row_from2['station_time']);
|
454
|
+
|
455
|
+
$time_to=strtotime($row_to['station_time']);
|
456
|
+
|
457
|
+
$time_to2=strtotime($row_to2['station_time']);
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
/*echo $time_from;
|
462
|
+
|
463
|
+
echo "<br/>";
|
464
|
+
|
465
|
+
echo $time_from;
|
466
|
+
|
467
|
+
echo "<br/>";
|
468
|
+
|
469
|
+
echo $time_to;
|
470
|
+
|
471
|
+
echo "<br/>";
|
472
|
+
|
473
|
+
echo $time_to2;
|
474
|
+
|
475
|
+
echo "<br/>";*/
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
if($time_from>$time_to){
|
480
|
+
|
481
|
+
$time_cal_result=$time_from-$time_to;
|
482
|
+
|
483
|
+
}else{
|
484
|
+
|
485
|
+
$time_cal_result=$time_to-$time_from;
|
486
|
+
|
487
|
+
}
|
488
|
+
|
489
|
+
if($time_from2>$time_to2){
|
490
|
+
|
491
|
+
$time_cal_result2=$time_from2-$time_to2;
|
492
|
+
|
493
|
+
}else{
|
494
|
+
|
495
|
+
$time_cal_result2=$time_to2-$time_from2;
|
496
|
+
|
497
|
+
}
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
if($time_cal_result==null||$time_cal_result2==null)echo "MISS4";
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
if($time_cal_result>$time_cal_result2)
|
508
|
+
|
509
|
+
{
|
510
|
+
|
511
|
+
echo date("i",$time_cal_result2);
|
512
|
+
|
513
|
+
}else{
|
514
|
+
|
515
|
+
echo date("i",$time_cal_result);
|
516
|
+
|
517
|
+
}
|
518
|
+
|
519
|
+
/*echo date("i",$time_cal_result)."Inner";
|
520
|
+
|
521
|
+
echo date("i",$time_cal_result2)."Outer";*/
|
522
|
+
|
523
|
+
}
|
524
|
+
|
525
|
+
/*if($time_cal_result>$time_cal_result2){
|
526
|
+
|
527
|
+
echo date("H:i",$time_cal_result2)."Inner".$row_to2['station_number'];
|
528
|
+
|
529
|
+
}else{
|
530
|
+
|
531
|
+
echo date("H:i",$time_cal_result)."Outer";
|
532
|
+
|
533
|
+
}*/
|
534
|
+
|
535
|
+
$db=null;
|
536
|
+
|
537
|
+
}catch(PDOException $e){
|
538
|
+
|
539
|
+
echo 'DB接続エラー:'.$e->getMessage();
|
540
|
+
|
541
|
+
}
|
542
|
+
|
543
|
+
}
|