Prev: I have some questions about this modified String class
Next: MAKE UPTO $5000 MONTHLY! $2000 INYOUR FIRST 30 DAYS!
From: Pen Ttt on 14 Jul 2010 06:35 when i run p1 ,i can get something like: Zimmer Holdings, Inc. Zion Oil & Gas Inc Zions Bancorporation Zions Bancorporation Zions Bancorporation Zions Bancorporation Zweig Fund, Inc. (The) Zweig Total Return Fund, Inc. (The) p1: require 'rubygems' require 'mysql' file=open('/home/pt/usastock/nasdaqcompanylist.csv','r') dbh = Mysql.real_connect("localhost", "root", "*****", "usastock") while line=file.gets line=line.chomp.split("\"") print line[3],"\n" end when i run p2,i can get nothing ,what's wrong? p2: require 'rubygems' require 'mysql' file=open('/home/pt/usastock/nasdaqcompanylist.csv','r') dbh = Mysql.real_connect("localhost", "root", "*****", "usastock") while line=file.gets line=line.chomp.split("\"") print line[3],"\n" sqlstr="insert into nasdaqname(name) values (?);" st=dbh.prepare(sqlstr) st.execute(#{line[3]}) end -- Posted via http://www.ruby-forum.com/.
From: Pen Ttt on 14 Jul 2010 06:44 require 'rubygems' require 'mysql' file=open('/home/pt/usastock/nasdaqcompanylist.csv','r') dbh = Mysql.real_connect("localhost", "root", "******", "usastock") sqlstr="insert into nasdaqname(name) values (?);" st=dbh.prepare(sqlstr) while line=file.gets line=line.chomp.split("\"") print line[3],"\n" st.execute(#{line[3]}) end i can get nothing whit that too. -- Posted via http://www.ruby-forum.com/.
From: Peter Hickman on 14 Jul 2010 06:50 Whats with this > st.execute(#{line[3]}) shouldn't you be using > st.execute(line[3]) the #{...} stuff is just for string interpolation
From: Pen Ttt on 14 Jul 2010 08:31
there two ways to do it after test 1.st.execute(line[3]) 2.st.execute("#{line[3]}") thinks -- Posted via http://www.ruby-forum.com/. |