passing string in a query to MySQL database in MATLAB -


i using mysql matlab, , want name user, , pass table in mysql, rejecting variable name in place of string

var_name=input('enter name:');  mysql('insert table (name) values (var_name)'); 

any suggestions?

i believe problem having same 1 in this other question. sounds want create command string contains ' delimited string, require escape each ' ' when create command string (note first example in this string handling documentation). note may want use 's' option input function:

var_name = input('enter name: ','s');  %# treats input string commandstring = sprintf('insert table (name) values (''%s'')', var_name);                             %# note 2 apostrophes --^ mysql(commandstring); 

if enter ken input, string commandstring contain following:

insert table (name) values ('ken') 

and of course, others have mentioned, beware injection vulnerabilities.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -