connect_errno) { echo "Failed to connect to MySQL: (" . $conn->connect_errno . ") " . $conn->connect_error; } else { debug("Successful Connection"); // debug($conn->host_info); } if($conn->select_db('ps2020')) { debug("Using ps2020"); } else { error($conn->error); } $username = $_GET["q"]; $sql = "SELECT * FROM user_account"; $result = $conn->query($sql); if($result->num_rows > 0){ while($row = $result->fetch_assoc()) { if($row["username"] == $username){ //So we have found an existing account //Username is already taken! echo "0"; break; } } } //Username is available echo "1"; $conn->close(); ?>