in the script, or running the script
sh -x /path/to/my/script
is almost mandatory when running Bash scripts for the first time.
I wonder if quoting the $i is done in the correct way. '$i' will not
be expanded by Bash and will be echoed as $i
Jan is right that "'$i'" again is expanded and will show 'value-of-i' including the single qoutes. But it is still tricky and prone to errors.
This is my standard way:
echo "UPDATE foo SET bar = \"$thit\" WHERE day = \"new\" "| mysql -u jlinkels -pmypass mydatabase.
It is a good idea to escape characters as '(' as well if you are not sure whether they mean something to Bash.
Escaping quotes like this never
gives me any problems or confusions in SQL statements, and you avoid qouting hell if you want to include a single or double qoute in one of the SQL values.