-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertLibrary.php
More file actions
58 lines (44 loc) · 1.39 KB
/
Copy pathinsertLibrary.php
File metadata and controls
58 lines (44 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
$id = $_POST["id"];
$library = $_POST["library"];
//$id = $_POST["id"];
//$pw = $_POST["pw"];
if($id==null ||$library==null){
echo "_GET ERROR<br>";
exit();
}
$host = 'localhost';//ip 주소
$user = 'wuddlaa';
$password = 'roqkfwk!2';
$dbName = 'wuddlaa';
$conn = mysqli_connect($host, $user, $password, $dbName); //디비 연결및 선택
if (!$conn) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
$data = array();
$sql = "SELECT * FROM Pallet_Library WHERE id='$id' AND library='$library';";
$result=mysqli_query($conn,$sql); //쿼리 수행결과 저장
$count = mysqli_num_rows($result);
if($count > 0){ //id Overlap check
//echo "ID Overlap, Query rows num : $count<br>";
echo json_encode($data["overlap"] = "overlap");
}
$sql = "INSERT INTO Pallet_Library VALUES('$id','$library');";
mysqli_query($conn,$sql);
$sql = "SELECT * FROM Pallet_Library WHERE id='$id' AND library='$library';";
$result=mysqli_query($conn,$sql); //쿼리 수행결과 저장
if(!$result)
echo mysqli_error($result)."<br>";
$count = mysqli_num_rows($result);
if($count == 1)
echo json_encode($data["overlap"] = "true");
else{
echo "Pallet_Library Insert Fail, Query rows num : $count<br>";
mysqli_close($conn);
exit();
}
mysqli_close($conn);
?>