Topic: Commands out of sync; you can't run this command now (Mysql::Error)

hi all

in my program,there are three datas in a sest:child,name,father;eg: a set's father may be another set'child,so that set's father must be the set'grandpa,and so on ,the last father must be "",it's the rule.

i have implement this function in ruby,

def dept_info(open_file_path,write_file_path)
    wFile=File.new(write_file_path,"w")
    arr||=File.readlines(open_file_path)
    arr.each_index do |ii|
      pc="#{arr[ii].split(',').last.delete("\n")}/#{arr[ii].split(',')[0]}"
      pc = getpc(pc,arr)
      p pc
      wFile.puts(pc)
   end
    wFile.close()
end

def getpc(pc,arr)
  f = arr.find {|item| pc.split("/")[0]==item.split(",")[0] }
  f.nil?? (return -1) : (pc = "#{f.split(",").last.delete("\n")}/#{pc}" )
  pc.split("/")[0].length==0? (return pc):(return getpc(pc ,arr))
end

but when i import the data into database and by database implement it.

there is error" `query': Commands out of sync; you can't run this command now (Mysql::Error)"

def getPC(msql,pc)
  while("#{pc.split("/")[0]}".length!=0)
  child = "#{pc.split("/")[0]}"
  parent = msql.query("SELECT * FROM info WHERE child="+"'#{child}'")
  parent.nil?? (return -1) : (pc = "#{parent}/#{getPC(msql,pc)}")
  end
end

or give me a better idea to implement this function.

thanks ,thanks very much

i am a rails rookie

Re: Commands out of sync; you can't run this command now (Mysql::Error)

sorry,i forget to paste the answer!

use the low version of mysql(lib) can solve those questions.

i am a rails rookie