I am using MySQL with MATLAB, and I want to get a name from user, and pass it to the table in mySQL, but it is rejecting a variable name in place of string
var_name=input('enter the name:');
mysql('insert into table (name) values (var_name)');
Any suggestions?
I believe the problem you are having is the same as the one in this other question. It sounds like you want to create a command string that itself contains a
'delimited string, which would require you to escape each'with another'when you create your command string (note the first example in this string handling documentation). Note also you may want to use the's'option for the INPUT function:If I were to enter
Kenfor the input, the stringcommandStringwould contain the following:And of course, as others have already mentioned, beware injection vulnerabilities.