user3243316
user3243316

Reputation: 1

How to get rid of syntax error, unexpected keyword_end, expecting end-of-input?

I was getting

syntax error, unexpected keyword_end, expecting end-of-input

in Command Prompt when trying to install and test ruby.

require 'mysql2'

client = Mysql2::Client.new(host: 'localhost', username: 'root', password: 'password1')

sql = 'select now() as timestamp'

result = client.query(sql)
    puts row['time stamp']
end

Upvotes: 0

Views: 613

Answers (1)

falsetru
falsetru

Reputation: 368944

The code is missing do.

client = Mysql2::Client.new(host: 'localhost', username: 'root', password: 'password1')

sql = 'select now() as timestamp'

result = client.query(sql) do # <----
    puts row['timestamp']
end

FYI, time stamp should be timestamp. (This is not direct cause of the syntax error).

Upvotes: 1

Related Questions