                 print("\(tableName) table could not be created.")
             }
         } else {
-            print("CREATE TABLE statement could not be prepared.")
+            let errMsg = String(cString: sqlite3_errmsg(db))
+            print("CREATE TABLE statement could not be prepared: \(errMsg)")
         }
 
         sqlite3_finalize(createTableStatement)

        sqlite3_finalize(insertStatement)
    }

    func openDatabase() -> OpaquePointer? {
        var db: OpaquePointer? = nil
        let dbPath = "lifesaver.db"
        if sqlite3_open(dbPath, &db) == SQLITE_OK {
            print("Successfully opened connection to database at \(dbPath)")
        } else {
            print("Unable to open database.")
        }
        return db
    }
    
    func createTables() {
        let userColumnsString = "Id INT PRIMARY KEY NOT NULL, Name CHAR(255)"
        createTable(tableName: "User", tableColumnsString: userColumnsString)
        
        let requestColumnsString = "Id INT PRIMARY KEY NOT NULL, User INT FOREIGN KEY, NotifyRadius INT, Call911 BOOL, EmergencyReason INT, OtherInfo CHAR(1024), Timestamp DOUBLE, Latitude FLOAT, Longitude FLOAT"
        createTable(tableName: "Request", tableColumnsString: requestColumnsString)
    }

    func createTable(tableName: String, tableColumnsString: String) {
        let createTableString = "CREATE TABLE IF NOT EXISTS \(tableName)(\(tableColumnsString));"
        var createTableStatement: OpaquePointer? = nil

        if sqlite3_prepare_v2(db, createTableString, -1, &createTableStatement, nil) == SQLITE_OK {

        let latitude = 45.5
        let longitude = 68.2
        
        let insertStatementString = "INSERT INTO Request (Id, UserId, NotifyRadius, Call911, EmergencyReason, OtherInfo, Timestamp, Latitude, Longitude) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"
        
        var insertStatement: OpaquePointer? = nil
        
