From: Brian Candler Date: 2011-11-04T02:29:43+09:00 Subject: Re: Inserting to the mysql table in ruby amir e. wrote in post #1030005: > I have a table and a phonebook program that I get information from users > and insert into the table , but because of I use two variable first and > second for information of users I can't Insert them into the table. my > code is below : > > def inserting > first = gets > second = gets > @connect.query('INSERT INTO person VALUES(first,second)') > end That's not complete code. What's the type of @connect? That is, what database API are you using? There are lots you could be using. Low-level: ruby-mysql and mysql-ruby. Medium-level: DBI. High-level: ActiveRecord, Sequel, DataMapper (which also let you drop out to low-level queries like you show). Also, what documentation did you follow to get to this point? Post the URL. It probably contains how to insert placeholders to bind values, or to quote values so that they can be interpolated safely into a SQL string. For example, DBI lets you do something like this (off the top of my head): @connect.query('INSERT INTO person VALUES(?,?)',first,second) -- Posted via http://www.ruby-forum.com/.