title: Failed to insert value into tables in Ruby Mysql
body: <p>I am trying to use Ruby to insert values into MySQL on localhost. The value i want to insert is the result from Twitter search. My program can successfully write the result to a file, so now i want to insert the result to MySQL. Here is part of my code:</p>
  
  <pre><code>results = @search.perform("yahoo", 100)
  client = Mysql2::Client.new(:host =&gt; "localhost", :username =&gt; "root", :password =&gt; "123", :database =&gt; "db1")
  results.map do |status|
  insert = client.query ("INSERT INTO table1 (fromuser, tweet) VALUES (#{status.from_user},#{status.text})")
  end
  </code></pre>
  
  <p>The error is "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "  tweet " at line 1 (Mysql2::Error).<br>
  What caused the error? </p>
  
  <p>Another problem i have found is that when i used following code to insert value to MySQL ,i got another error: "Unknown column 'a' in 'field list' (Mysql::ServerError::BadFieldError)" </p>
  
  <pre><code>require 'mysql'
  require 'rubygems'
  sql = Mysql.real_connect("localhost", "root", "123", "db1")
  st1 = "a"
  st2 = "b"
  user_string = "(#{st1},#{st2})"
  query="INSERT INTO table1 (fromuser, tweet) VALUES" + user_string
  sql.query(query)
  </code></pre>
  
  <p>I want to insert "a" and "b" into table.
  How to solve this?</p>
  
  <p>Thanks in advance, </p>