title: why doesnt this Javascript work when mixed with php?
body: <p>im trying to grab search items from twitter via PHP curl, process and update them every second. In this simple version im just trying to refresh the search results for "bieber" every second. i have combined php with the javascript and im guessing its the reason things don't work...but I need to understand why. In my understanding Apache sends only html back to the browser...so why is there a problem with the innerHTML specification:
  Here's the script</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type = 'text/javascript'&gt;
  
  
  function refresh(){
  document.getElementById('target').innerHTML= &lt;?
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,'http://search.twitter.com/search.json?q=bieber&amp;rpp=100');
  
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  
  $var = curl_exec($ch);
  
  
  curl_close($ch);
  
  $obj = json_decode($var, true);
  
  
  
  for($i = 0; $i&lt;500; $i++){
  if(empty($obj['results'][$i]['text'])){
   echo $i;
   break;
      }
  echo $obj['results'][$i]['text']."&lt;br/&gt;";
  }
  
  ?&gt;
  ;
  var refresher = setTimeout("refresh()",1000);
  
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body onLoad="refresh()"&gt;
  &lt;div&gt;
  &lt;span&gt; stuff &lt;/span&gt;
  &lt;div id ='target'&gt;
  &lt;/div&gt;
  
  
  &lt;div id= 'rest'&gt;
  The Rest of the page that does not refresh
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I know there's AJAX and JQuery etc but let's mention them only after we've explained to me why there's a problem with this code and why what im doing is not possible without those technologies.</p>
  
  <p>Thanks!</p>