<?php
$options = [
    PDO::ATTR_PERSISTENT => false,
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_EMULATE_PREPARES => false,
    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'
];

try {
    $pdo = new PDO('mysql:host=127.0.0.1;port=3306;dbname=app', 'root', 'my551sql', $options);
    $pdo->exec('SET CHARACTER SET utf8mb4');
} catch (PDOException $e) {
    throw new PDOException($e->getMessage());
}

$sql = 'SELECT * FROM apps WHERE tax_id = :sn';
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':sn', (isset($_GET['tax_ID']))?$_GET['tax_ID']:$argv['1']);
$stmt->execute();

$data = $stmt->fetch(PDO::FETCH_ASSOC);
if($data){
        echo 'https://app.551.com.tw/apps/'.$data['tax_id'].'/einv';
}else{	
	echo 'https://app.551.com.tw';
}
unset($PDO);
