jeudi 16 juin 2016

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server

I have this code:

ANZ=`mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT count(id) FROM $TABLE WHERE deleted=1 and not lastname='anonym';" --skip-column-names -B;`;
if [ $((ANZ)) -gt 0 ]
then
mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT id, username FROM $TABLE WHERE deleted=1 and not lastname='anonym' and username like '%@%';" --skip-column-names -B > $FILE;

cat $FILE | while read TMP

do
echo "temp:" ${TMP%   *};

    UserID=${TMP%   *};
    echo $UserID >> $RES_FILE;

    echo "User $UserID wird anonymisiert...";
echo $UserID;

echo '`mysql -u$USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE $TABLE SET username="'$A$UserID'", email='a@nonym.de', firstname='$A', lastname='$A', icq='', skype='', yahoo='', aim='', msn='', phone1='', phone2='', institution='', dep$
echo'        `mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_message SET subject='Neue Mitteilung von anonym' WHERE useridfrom=$UserID;"`';
echo'        `mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_message_read SET subject='Neue Mitteilung von anonym' WHERE useridfrom=$UserID;"`';
    VNAME=`mysql -N -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT firstname FROM $TABLE WHERE id=$UserID;"`;
   NNAME=`mysql -N -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "SELECT lastname FROM $TABLE WHERE id=$UserID;"`;
     `mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_event SET name='Meeting with your Student, anonym' WHERE name LIKE 'Meeting with your Student,%$VNAME $NNAME%';"`;

done
echo
"Finish!"

And the error I'm getting is:

mysql -u$USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE $TABLE SET username="anonym611 demo@XXXXX.de.1456411291", email=a@nonym.de, firstname=anonym, lastname=anonym, icq=, skype=, yahoo=, aim=, msn=, phone1=, phone2=, institution=, department=, address=, city=, country=, url= WHERE deleted=1 AND id=611 demo@XXXXX.de.1456411291;" ./anonym.sh: Zeile 50: echo
mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_message SET subject=Neue: command not found. ./anonym.sh: Zeile 52: echo `mysql -u $USER -p$PASSWD -h$HOST -D $DATABASE -e "UPDATE mdl_message_read SET subject=Neue: command not found.

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'demo@xxxxxxx.de.1456411291' at line 1

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'demo@xxxxxxxxxx.de.1456411291' at line 1

Aucun commentaire:

Enregistrer un commentaire