From: Pen Ttt on
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
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
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
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/.