[SOLVED]Help: Relational Database Number Guess Game

Hello. Even though I get the necessary output, the tasks don’t get checked. I couldn’t figure out what is the issue. Can somebody help?
Tasks that are unchecked:
1.) If that username has been used before, it should print Welcome back, <username>! You have played <games_played> games, and your best game took <best_game> guesses. , with <username> being a users name from the database, <games_played> being the total number of games that user has played, and <best_game> being the fewest number of guesses it took that user to win the game
2.) When the secret number is guessed, your script should print You guessed it in <number_of_guesses> tries. The secret number was <secret_number>. Nice job!

`#!/bin/bash
PSQL=“psql --username=freecodecamp --dbname=number_guess -t --no-align -c”

echo “Enter your username:”
read USERNAME

USER_CHECK=$($PSQL “SELECT username FROM user_info WHERE username=’$USERNAME’”)

if [[ -z $USER_CHECK ]]
then
echo -e “Welcome, $USERNAME! It looks like this is your first time here.”
ADD_USER=$($PSQL “INSERT INTO user_info(username) VALUES(’$USERNAME’)”)
else
DB_USERNAME=$($PSQL “SELECT username FROM user_info WHERE username=’$USERNAME’”)
GAMES_PLAYED=$($PSQL “SELECT games_played FROM user_info WHERE username=’$USERNAME’”)
BEST_GAME=$($PSQL “SELECT best_game FROM user_info WHERE username=’$USERNAME’”)
echo “Welcome back, $DB_USERNAME! You have played $GAMES_PLAYED games, and your best game took $BEST_GAME guesses.”
fi

echo -e “Guess the secret number between 1 and 1000:”
G_NUMBER=$(($RANDOM % 1000 + 1))
read USER_INPUT
let COUNT=0

until [ $USER_INPUT -eq $G_NUMBER ]; do
while [ $((USER_INPUT)) != $USER_INPUT ]; do
echo “That is not an integer, guess again:”
read USER_INPUT
done

while [ $USER_INPUT -gt $G_NUMBER ]; do
echo “It’s lower than that, guess again:”
read USER_INPUT
let COUNT++
done

while [ $USER_INPUT -lt $G_NUMBER ]; do
echo “It’s higher than that, guess again:”
read USER_INPUT
let COUNT++
done
done

echo “You guessed it in $COUNT tries. The secret number was $G_NUMBER. Nice job!”
INCREMENT_GAMES_PLAYED=$($PSQL “UPDATE user_info SET games_played=games_played+1 WHERE username=’$USERNAME’”)
UPDATE_BEST_GAME=$($PSQL “UPDATE user_info SET best_game=$COUNT WHERE username=’$USERNAME’ AND (best_game>$COUNT OR best_game ISNULL)”)
`

Hello. I have been getting the necessary output, but I don’t get the checkmarks for two tasks. It’s been two days and I couldn’t figure out why. I have checked if there is something wrong with the output (shuch as a space in the end, etc.) by comparing the outputs individually, but they are completely the same.

The tasks that I don’t get the checkmark are:

  1. If that username has been used before, it should print Welcome back, <username>! You have played <games_played> games, and your best game took <best_game> guesses. , with <username> being a users name from the database, <games_played> being the total number of games that user has played, and <best_game> being the fewest number of guesses it took that user to win the game.
  2. When the secret number is guessed, your script should print You guessed it in <number_of_guesses> tries. The secret number was <secret_number>. Nice job!
#!/bin/bash

PSQL="psql --username=freecodecamp --dbname=number_guess -t --no-align -c"

echo "Enter your username:"

read USERNAME

USER_CHECK=$($PSQL "SELECT username FROM user_info WHERE username='$USERNAME'")

if [[ -z $USER_CHECK ]]

then

  echo -e "Welcome, $USERNAME! It looks like this is your first time here."

  ADD_USER=$($PSQL "INSERT INTO user_info(username) VALUES('$USERNAME')")

else

  DB_USERNAME=$($PSQL "SELECT username FROM user_info WHERE username='$USERNAME'")

  GAMES_PLAYED=$($PSQL "SELECT games_played FROM user_info WHERE username='$USERNAME'")

  BEST_GAME=$($PSQL "SELECT best_game FROM user_info WHERE username='$USERNAME'")

  echo "Welcome back, $DB_USERNAME! You have played $GAMES_PLAYED games, and your best game took $BEST_GAME guesses."

fi

echo -e "Guess the secret number between 1 and 1000:"

G_NUMBER=$(($RANDOM % 1000 + 1))

read USER_INPUT

let COUNT=0

until [ $USER_INPUT -eq $G_NUMBER ]; do

  while [ $((USER_INPUT)) != $USER_INPUT ]; do

    echo "That is not an integer, guess again:"

    read USER_INPUT

  done

 

  while [ $USER_INPUT -gt $G_NUMBER ]; do

    echo "It's lower than that, guess again:"

    read USER_INPUT

    let COUNT++

  done

  while [ $USER_INPUT -lt $G_NUMBER ]; do

    echo "It's higher than that, guess again:"

    read USER_INPUT

    let COUNT++

  done

done

echo "You guessed it in $COUNT tries. The secret number was $G_NUMBER. Nice job!"

INCREMENT_GAMES_PLAYED=$($PSQL "UPDATE user_info SET games_played=games_played+1 WHERE username='$USERNAME'")

UPDATE_BEST_GAME=$($PSQL "UPDATE user_info SET best_game=$COUNT WHERE username='$USERNAME' AND (best_game>$COUNT OR best_game ISNULL)")

I saw in the title that you solved it, right? How did you solve it? It’s the same situation I’m stuck in right now.

Started to count from 0 after getting the user input:))) Spent 2 days, recoded it 3 times just to find out I was counting wrong this whole time:)