Guest

This REGEXP echos one thing, but enters into MySQL another. Why

By: a guest on Jan 28th, 2012  |  syntax: None  |  size: 1.59 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. $url = "http://search.twitter.com/search.json?q=&ands=&phrase=&ors=&nots=RT%2C+%40&tag=andyasks&lang=all&from=amcafee&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=50";
  2. $contents = file_get_contents($url);
  3. $decode = json_decode($contents, true);
  4. foreach($decode['results'] as $current) {
  5.     if(preg_match("/?/", "$current[text]")){
  6.     echo $current[text]."<br />";
  7.     }
  8. }
  9.        
  10. $url = "http://search.twitter.com/search.json?q=&ands=&phrase=&ors=&nots=RT%2C+%40&tag=andyasks&lang=all&from=amcafee&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=50";
  11.     $contents = file_get_contents($url);
  12.     $decode = json_decode($contents, true);
  13.     foreach($decode['results'] as $current) {
  14.         $query = "INSERT IGNORE INTO andyasks (questions, date, user) VALUES ('$current[text]','$current[created_at]','Andy')";
  15.         if(preg_match("/?/", "$current[text]")){
  16.         mysql_query($query);
  17. }
  18. }
  19.        
  20. $url = "http://search.twitter.com/search.jsonq=&ands=&phrase=&ors=&nots=RT%2C+%40&tag=andyasks&lang=all&from=amcafee&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=50";
  21. $contents = file_get_contents($url);
  22. $decode = json_decode($contents, true);
  23. foreach($decode['results'] as $current)
  24. {
  25.     $query = "INSERT IGNORE INTO andyasks (questions, date, user) VALUES ('$current[text]','$current[created_at]','Andy')";
  26.     if(preg_match("/?/", "$current[text]"))
  27.     {
  28.     mysql_real_escape_string($query);
  29.     mysql_query($query);
  30.     }
  31.  }
  32.        
  33. class BrainDeadLogger {
  34.         static public function log($output, $file='/tmp/test.txt') {
  35.                 file_put_contents($file,"$outputn",FILE_APPEND);
  36.         }
  37. }      
  38. BrainDeadLogger::log($sql);
  39.        
  40. tail -f /tmp/test.txt