I have a database named “crea” with a table named “assets” and in this table i have 11 column named (name,description,assetType,local,temporary,data,id,create_time,access_time,asset_flags,CreatorID)
I also have a directory folder with many picture in .jp2 format (xxxx.jp2)
What im trying to do is to bulk insert these picture in the table “assets” of my database, so i decided to do it with 2 shell scripts, the both are in the directory with the pictures.
When i launch ./assetadd.sh from the terminal, i get this error from MySQL :
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near ‘??,asset_flags,CreatorID) VALUES at line 1
I dont understan what is wrong with these scripts and where the syntax error is … i checked many time the name of the table/column to see if i have made an error but all look good.
If someone have a little time to take a look a these scripts and tell me what is wrong this will be really apreciated.
Thank you
PS: My OS is Ubuntu 11.10
– Script 1 : assetsadd.sh
#!/bin/bash
path=$(pwd)
find $path/ -type f \( -iname *.jp2 \) -exec ./insertjp2.sh {} \;
echo "finished!!"
– Script 2 : insertjp2.sh
#!/bin/bash
user="crea"
password="crea"
database="crea"
dbhost="localhost"
creator="crea"
param=$@
basenam=${param##*/}
filenam=${basenam%.*}
MYSQL=`/usr/bin/mysql -u$user -p$password -D$database -e"INSERT INTO assets (name,description,assetType,local,temporary,data,id,create_time,access_time,asset_flags,CreatorID) VALUES ('$filenam','$filenam',0,0,0,LOAD_FILE('$param'),'$filenam',UNIX_TIMESTAMP(),1325304546,0,'$creator' );"`
echo $param >> assetadd.log
echo $MYSQL
You seem to have a weird or non-printable character right at the point of the error message: