title: Passing output from R to php
body: <p>So I am trying to use php to run an R code that just adds 3 inputted numbers together and returns the results to php. The php R connection works and will print results to my website if I include a print statement in my R code, however I want to store the output results in a variable $output. When I used this exec statement nothing gets stored into $output. Thanks for the help </p>
  
  <p>R CODE:</p>
  
  <pre><code>args = commandArgs(TRUE)
  file1 = as.numeric(args[1])
  file2 = as.numeric(args[2])
  file3 = as.numeric(args[3])
  
  output = file1+file2+file3
  ans2 = data.frame(output)
  
  mydb = dbConnect(MySQL(), user = "g1076652", password = "******", dbname = "g1076652", host = "mydb.ics.purdue.edu")
  on.exit(dbDisconnect(mydb))
  
  dbWriteTable(mydb,value=ans2,name="Test",append=TRUE,row.names=FALSE)
  dbDisconnect(mydb)
  </code></pre>
  
  <p>PHP CODE:</p>
  
  <pre><code>&lt;?php
  exec("Rscript testwebsite.R $file1 $file2 $file3", $output);
  echo $output;
  </code></pre>