function db_connect() { $result = new mysqli('localhost', 'root', '654321', 'smsprj'); //$result = new mysqli('localhost', 'root', '654321'); if (!$result) { throw new Exception('データベースサーバーに接続できませんでした'); } else {
return $result; } }
?>
$conn = db_connect(); $sql = $conn->query("SELECT * FROM user");