
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
$url = "http://search.twitter.com/search.json?q=&ands=&phrase=&ors=¬s=RT%2C+%40&tag=andyasks&lang=all&from=amcafee&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=50";
$contents = file_get_contents($url);
$decode = json_decode($contents, true);
foreach($decode['results'] as $current) {
if(preg_match("/?/", "$current[text]")){
echo $current[text]."<br />";
}
}
$url = "http://search.twitter.com/search.json?q=&ands=&phrase=&ors=¬s=RT%2C+%40&tag=andyasks&lang=all&from=amcafee&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=50";
$contents = file_get_contents($url);
$decode = json_decode($contents, true);
foreach($decode['results'] as $current) {
$query = "INSERT IGNORE INTO andyasks (questions, date, user) VALUES ('$current[text]','$current[created_at]','Andy')";
if(preg_match("/?/", "$current[text]")){
mysql_query($query);
}
}
$url = "http://search.twitter.com/search.jsonq=&ands=&phrase=&ors=¬s=RT%2C+%40&tag=andyasks&lang=all&from=amcafee&to=&ref=&near=&within=15&units=mi&since=&until=&rpp=50";
$contents = file_get_contents($url);
$decode = json_decode($contents, true);
foreach($decode['results'] as $current)
{
$query = "INSERT IGNORE INTO andyasks (questions, date, user) VALUES ('$current[text]','$current[created_at]','Andy')";
if(preg_match("/?/", "$current[text]"))
{
mysql_real_escape_string($query);
mysql_query($query);
}
}
class BrainDeadLogger {
static public function log($output, $file='/tmp/test.txt') {
file_put_contents($file,"$outputn",FILE_APPEND);
}
}
BrainDeadLogger::log($sql);
tail -f /tmp/test.txt