$dbcs = new mysqli('localhost', 'hyeri0418', 'Music0418', 'hyeri0418');
//mysql 열기 성공 체크
if(mysqli_connect_errno()) {
	echo 'DBERROR';
	mysqli_close($dbcs);
	exit;
}
$query = "select count(*) as total from xe_mtga_cards";
	
			
	if(!$result = $dbcs->query($query)) {
		echo "해당 이벤트 데이터베이스가 존재하지 않습니다. 
관리자에게 문의하십시오.";
		mysqli_close($db);
		exit();
		}
	
if($result->num_rows != 1) // 이 경우 뭔가 이상한거
{
    echo "";
    exit();
}
$row = $result->fetch_assoc();
$cid = mt_rand(1, $row['total']);
$query = "select * from xe_mtga_cards where `cid` = ".$cid;
if(!$result = $dbcs->query($query)) {
    echo "해당 이벤트 데이터베이스가 존재하지 않습니다. 
관리자에게 문의하십시오.";
    mysqli_close($db);
    exit();
    }
$row = $result->fetch_assoc();
echo "";
// 이상이 없으면 자료 뽑고 시작.
?>