1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php $mysqli = new mysqli('localhost:3307','phpuser','1234','phpuser_db'); if ($mysqli->connect_errno) { die("Failed to connect to MySQL: (" .$mysqli->connect_errno.") ".$mysqli_error); } if(!$result = $mysqli->query("select count from counter")){ if(!$mysqli->query("create table counter (count int)")|| !$mysqli->query("insert into counter value (0)")){ die("Table creation failed : (". $mysqli_errno.") ".$mysqli_error); } } $mysqli->query("update counter set count=count+1"); $result = $mysqli->query("select count from counter"); $row = $result->fetch_row(); echo "방문횟수 : ".$row[0]; $result->free(); $mysqli->close(); ?> | cs |
'php' 카테고리의 다른 글
주소록 (0) | 2018.03.27 |
---|---|
설문조사 (0) | 2018.03.27 |
Warning: mysqli_connect(): (HY000/1045): Access denied for user 오류 (0) | 2018.03.27 |
Fatal error: Uncaught Error: Call to undefined function mysql_connect() (0) | 2018.03.26 |
간단한 로그인 처리 (0) | 2018.03.26 |