What's proble with ruby-mysql-prepare?

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

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.

Whats with this

st.execute(#{line[3]})

shouldn’t you be using

st.execute(line[3])

the #{…} stuff is just for string interpolation

there two ways to do it after test
1.st.execute(line[3])
2.st.execute("#{line[3]}")
thinks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs