How to break down tuple from Python to PHP -
i'm using http post request codeigniter python , return tuple mysql python
codeigniter controller:
$data['email'] = $this->input->post("email"); $url = 'http://domain/path'; $data = array('email' => $data['email']); // use key 'http' if send request https://... $options = array( 'http' => array( 'header' => "content-type: application/x-www-form-urlencoded\r\n", 'method' => 'post', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); var_dump($result);
python code:
elif self.path=="/forgotpass": print "forgot password module" form = cgi.fieldstorage( fp=self.rfile, headers=self.headers, environ={'request_method':'post', 'content_type':self.headers['content-type'], }) self.send_response(200) self.send_header('content-type','text/html') self.send_header("access-control-allow-origin","http://domain") self.end_headers() #print form['email'].value email = str(form["email"].value) sql = "select email_address, personal_id personal_info email_address='"+email+"'" result = validate(sql) print result #print email; self.wfile.write(result) def validate(sql): try: db = mysqldb.connect("localhost","root","password","schema" ) cnn = db.cursor() cnn.execute(sql) return cnn.fetchone() cnn.close() except mysqldb, e: print "error validate function"
the display is, think string format.
string(36) "('jerahmeel.acebuche@smsgt.com', 2l)"
in simple codeigniter connecting model.
the result of array mysql is:
array (column => value) etc etc..
you display array using foreach , $item->data;
but result came python tuple , returning php different approach.
how break tuple in php? or should break on python , return php?
Comments
Post a Comment