title: How to Connect PHP and Python
body: <p>I have 2 system, the interface I build with PHP and the machine is build with python because I use fuzzy in python.</p>
  
  <p>I have to try get the specific data with PHP and that work</p>
  
  <p>And i have make a function with python to recieve a variable and that work</p>
  
  <p>But I have a problem</p>
  
  <p>The problem is, how to throw a variabel from MySQL with PHP and process it with python ?</p>
  
  <p>after that finish the process, how to throw back the result to PHP and then send to mySQL databases?</p>
  
  <p>The code in php like this, the code is to grab the data from sql</p>
  
  <pre><code>function fuzzy($id = '')
      {   
          $data_sg1 = core::selectWhereCollums('area_proses','default','sg1',array('id'=&gt;$id));
          $data_sg2 = core::selectWhereCollums('area_proses','default','sg2',array('id'=&gt;$id));
          $data_sg3 = core::selectWhereCollums('area_proses','default','sg3',array('id'=&gt;$id));
  
  
          $this-&gt;session-&gt;set_flashdata('success','success');
          redirect('area_proses');
      }
  </code></pre>
  
  <p>and the code in python like this</p>
  
  <pre><code>def hitung_fuzzy(masukan_sg1, masukan_sg2, masukan_sg3):
      sg1 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg1')
      sg2 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg2')
      sg3 = fuzz.Antecedent(np.arange(0, 5, 1), 'sg3')
  
  ---------------------
  --------------------
  
  ####################################################
  #Masukan
  start_time = time.time()
  a = float(input("Masukan SG1: "))
  b = float(input("Masukan SG2: "))
  c = float(input("Masukan SG3: "))
  
  z = hitung_fuzzy(a,b,c)
  
  print ("--------------------------------\n")
  print ("Hasil Perhitungan:\n")
  print (z)
  print ("--------------------------------\n")
  print ("Waktu proses adalah :\n")
  print("%s detik\n" % (time.time() - start_time))
  print ("--------------------------------\n")
  raw_input("Tekan enter untuk keluar")
  </code></pre>