title: MySQL query variable not accepted
body: <p>I am working on a PHP script that should get data from MySQL.</p>
  
  <p>Here is what am I doing:</p>
  
  <pre><code>&lt;?php
  include('db.php');
  session_start();
  $doctor_actual=$_SESSION['doctor_actual'];
  echo $doctor_actual;
   if(isset($_REQUEST['actionfunction']) &amp;&amp; $_REQUEST['actionfunction']!=''){
  $actionfunction = $_REQUEST['actionfunction'];
  
     call_user_func($actionfunction,$_REQUEST,$con,$limit,$adjacent);
  }
  function showData($data,$con,$limit,$adjacent){
    $page = $data['page'];
     if($page==1){
     $start = 0;  
    }
    else{
    $start = ($page-1)*$limit;
    }
    $sql = "select * from tb_opiniones_doctor where codigo_verificacion = '".$doctor_actual."' order by id_opinion_doctor asc";
    $rows  = $con-&gt;query($sql);
    $rows  = $rows-&gt;num_rows;
  
    $sql = "select * from tb_opiniones_doctor where codigo_verificacion = '".$doctor_actual."'  order by id_opinion_doctor asc limit $start,$limit";
  
    $data = $con-&gt;query($sql);
    $str='&lt;table&gt;&lt;tr class="head"&gt;&lt;td&gt;Id&lt;/td&gt;&lt;td&gt;Firstname&lt;/td&gt;&lt;td&gt;Lastname&lt;/td&gt;&lt;/tr&gt;';
    if($data-&gt;num_rows&gt;0){
     while( $row = $data-&gt;fetch_array(MYSQLI_ASSOC)){
        $str.="&lt;tr&gt;&lt;td&gt;".$row['id_opinion_doctor']."&lt;/td&gt;&lt;td&gt;".$row['id_opinion_doctor']."&lt;/td&gt;&lt;td&gt;".$row['id_opinion_doctor']."&lt;/td&gt;&lt;/tr&gt;";
     }
     }else{
      $str .= "&lt;td colspan='5'&gt;No Data Available&lt;/td&gt;";
     }
     $str.='&lt;/table&gt;';
  
  echo $str; 
  pagination($limit,$adjacent,$rows,$page);  
  }
  </code></pre>
  
  <p>My problems are at the two queries, they only work if I put the real value for $doctor_actual, not as variable.</p>
  
  <p>I have echoed the value for $doctor_actual, it is 9dv2ACvtwn2.</p>
  
  <p>If I put in the queries ..where codigo_verificacion = "9dv2ACvtwn2"... the queries work fine.</p>
  
  <p>If I put:</p>
  
  <pre><code>codigo_verificacion = '".$doctor_actual."'
  </code></pre>
  
  <p>or</p>
  
  <pre><code>codigo_verificacion = '.$doctor_actual.'
  </code></pre>
  
  <p>or</p>
  
  <pre><code>codigo_verificacion = $doctor_actual
  </code></pre>
  
  <p>it shows the message:</p>
  
  <pre><code>No Data Available
  </code></pre>