My problem is very strange. I am pulling users tweets off of twitter.com and trying to store them into a mysql database. Here is how I created the database:
CREATE TABLE tweets ( id int unsigned not null PRIMARY KEY auto_increment, published blob, content blob, link blob );
So, it will pull the first 3 tweets and put them in there, but stops at 4. Without the SQL statement it prints the values on the command line. Thank for the help in advance guys! The error I get is
You have an error in your SQL Syntax; check the manual that correspond +s with your MYSQL server version to use near 's Nuclear Security Summ +it -- focusing on solutions top keep nuclear materials away
#!/usr/bin/perl use warnings; use strict; use XML::RSS; use LWP::Simple; use DBI; my $user="root"; my $password="root"; my $database="forex"; # Connect to the database. my $dbh = DBI->connect("DBI:mysql:database=forex;host=localhost", "root", "root", {'RaiseError' => 1}); # Get the source file my $source = get("http://twitter.com/statuses/user_timeline/813286.rss +"); # Create a new XML:RSS object my $rss = new XML::RSS (version => '2.0'); # Parse the file into the XML::RSS object $rss->parse($source); # For example print titles and links of each RSS item foreach my $item (@{$rss->{'items'}}) { my $published = $item->{'pubDate'}; my $content = $item->{'title'}; my $link = $item->{'link'}; #print $published . "\n"; #print $content . "\n"; #print $link . "\n\n"; my $sth=$dbh->prepare("INSERT INTO tweets (published, content, link) V +ALUES ('$published', '$content', '$link')"); $sth->execute(); }

In reply to Tweets to a database by gbotzz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.