Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP output buffering variable
    primarykey
    data
    text
    <p>Is it possible to use a POST variable on the buffered script? The code is the following</p> <pre><code>&lt;?php header('Content-type: application/json'); $someVar= $_POST["var"]; ob_start(); require "someScript.php?var=" . $someVar; // instead of passing through GET, is there a way to use the $someVar directly? $output = ob_get_clean(); echo $output; ?&gt; </code></pre> <p>Note: I've already tried to access $someVar directly from someScript but without success. For that is why I'm asking. Thanks</p> <p>EDIT: Possible someScript.php</p> <pre><code>&lt;?php header('Content-type: application/json'); require_once("BD.php"); require_once("json/json_header.php"); require_once("tools.php"); require_once('class.phpmailer.php'); $BD = new BDInfo(); function encodeIDs($id1,$id2){ // doesn't matter } $response = array("errorCode" =&gt; 0, "errorDesc" =&gt; "No Error"); if(isset($someVar)){ try{ $link = mysqli_connect($BD-&gt;BDServer, $BD-&gt;BDUsername, $BD-&gt;BDPassword); if( !$link ) throw new Exception( "..." ); if( !mysqli_select_db($link, $BD-&gt;BDDatabase) ) throw new Exception( "..." ); $SQL="SELECT (...) us.VAR='" . $someVar . "';"; $RS = mysqli_query($link,$SQL); if($RS &amp;&amp; $row = mysqli_fetch_array($RS)){ // process query result } else { $response["errorCode"]=4; $response["errorDesc"]="Error descr"; } mysqli_close($link); }catch (Exception $e) { $response["errorCode"]=1; $response["errorDesc"]="Database Error: " . $e-&gt;getMessage(); } }else{ $response["errorCode"]=2; $response["errorDesc"]="Invalid Parameters"; } echo json_encode($response); ?&gt; </code></pre> <p>I get Invalid Parameters, showing that isset($var) failed</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload