mysql - strangeproblem with http request URL Parameter in web service php -


guys i'm working on developing app , have strange problem. have database , web service, wrote number of procedures , functions in database , work within environment mysql, when use url request, not show true query (always run else condition , show me record 'xxxx' record response when understand send data isn't true , invalid , not show me blank json '[ ]'), things test, character set,... (all things been comments) please me in below you're showing code in web service , mysql: php side , web service:

<?php if (isset($_request['action'])) { $action = $_request['action']; } else { echo "invalid data"; exit; } switch ($action) { case "getrecord" : getrecord($_request['id'], $_request['email'], $_request['mobile']); break; . . . . default: echo "your action select not true!"; }  function getrecord($id, $email, $mobile) { $con = mysqli_connect("localhost", "root", "root", "mydb"); /*mb_detect_encoding($id,"ascii"); mb_detect_encoding($mobile,"ascii"); mb_detect_encoding($email,"ascii");*/ mb_convert_encoding($id, 'ascii'); mb_convert_encoding($email, 'ascii'); mb_convert_encoding($mobile, 'ascii');  if (mb_check_encoding($id, "utf-8")) { echo "utf-8 yes!!!" . php_eol; } if (mb_check_encoding($email, "utf-8")) { echo "utf-8 yes!!!" . php_eol; } if (mb_check_encoding($mobile, "utf-8")) { echo "utf-8 yes!!!" . php_eol; }   if (mb_check_encoding($id, "ascii")) { echo "ascii yes!!!" . php_eol; } if (mb_check_encoding($email, "ascii")) { echo "ascii yes!!!" . php_eol; } if (mb_check_encoding($mobile, "ascii")) { echo "ascii yes!!!" . php_eol; } if (is_int($id)) { echo "id integer yes!!!" . php_eol; } else { echo "id not integer!!!" . php_eol; }  if (is_int($email)) { echo "email integer yes!!!" . php_eol; } else { echo "email not integer!!!" . php_eol; }  if (is_int($mobile)) { echo "mobile integer yes!!!" . php_eol; } else { echo "mobile not integer!!!" . php_eol; } ////////////////////////////// if (is_string($id)) { echo "id string yes!!!" . php_eol; } else { echo "id not string!!!" . php_eol; }  if (is_string($email)) { echo "email string yes!!!" . php_eol; } else { echo "email not string!!!" . php_eol; }  if (is_string($mobile)) { echo "mobile string yes!!!" . php_eol; } else { echo "mobile not string!!!" . php_eol; }   //$sql = "set @p0=''$id''; set @p1=''$email''; set @p2=''$mobile''; call `getrecord`(@p0, @p1, @p2);"; //$sql = "call getrecord(''$id'',''$email'',''$mobile'');"; //$sql = "call getrecord(" + "'$id'" + "," + "'$email'" + "," + "'$mobile'" + ");"; //$sql = "call getrecord(" + "'$id'" + "," + "'$email'" + "," + "'$mobile'" + ");"; //$sql = "call getrecord('2261','saleh@gmail.com','+989999999999');";//this state word too, , show me true query  $sql = "call getrecord('$id','$email','$mobile');"; if (mysqli_connect_errno()) { echo "failed connect mysql server" . mysqli_connect_error(); } mysqli_set_charset($con, "ascii"); $resualt = mysqli_query($con, $sql); $records = array(); while ($row = mysqli_fetch_array($resualt)) { $record = array(); $record['id'] = $row['id']; $record['name'] = $row['name']; $record['family'] = $row['family']; $record['birthdate'] = $row['birthdate']; $record['email'] = $row['email']; $record['mobile'] = $row['mobile']; $records[] = $record; } echo json_encode($records); mysqli_close($con); } 

sql side , procedure code :

delimiter $$ create procedure `getrecord` (in id varchar(166) character set ascii, in email varchar(166) character set ascii , in mobile varchar(166) character set ascii)  begin declare checkme varchar(166); declare countrecords int; set checkme = ( select count(*) persons persons.email = email , persons.mobile = mobile); if checkme = 1 select * persons persons.id = id; else  select * persons persons.id = 'xxxx'; end if ; end $$ delimiter ; 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -