Problems taking the variables with REQUEST AND POST

2

I am trying to use a variable that I have brought with $_REQUEST[] and then in a condition where I say that if the method was POST, I execute a query in which I use that variable but it does not take it correctly.

This is the code, the variable that I need to use is $fad_id and can be used in the query:

$fad_id = $_REQUEST['fad_id']; <br>
$modo = $_REQUEST['modo'];

if ($_SERVER[REQUEST_METHOD] == "POST")
{   
    $sql = "SELECT fat_id FROM fat_mstr WHERE fad_id = $fad_id";
    $db->ejecutar($sql);

    while ($val=$db->traer_datos_num()) {
        $fat_id=$val[0];
    }

    var_dump($fat_id);
?>
    
asked by Manuel Mosquera 19.05.2016 в 16:55
source

2 answers

1

You have forgotten the quotes in the variable $ _SERVER [REQUEST_METHOD]

$_SERVER['REQUEST_METHOD']
    
answered by 20.05.2016 в 16:11
-1

did you mean

  $fad_id = $_REQUEST['fad_id']; <br>
  $modo = $_REQUEST['modo'];

  if ($_SERVER['REQUEST_METHOD'] == 'POST')
  {   
      $sql = "SELECT fat_id FROM fat_mstr WHERE fad_id = $fad_id";
      $db->ejecutar($sql);

      while ($val=$db->traer_datos_num()) {
          $fat_id=$val[0];
      }

      var_dump($fat_id);
  ?>
    
answered by 19.05.2016 в 18:15