带有http请求URL的奇怪问题web服务php中的参数

时间:2017-04-07 05:16:45

标签: php mysql web-services stored-procedures httprequest

伙计我正在开发应用程序,我有一个非常奇怪的问题。我有一个数据库和一个Web服务,我在数据库中编写了一些程序和函数,并且在MySql环境中都很好用,但是当我使用URL请求时,不显示真正的查询(总是运行其他条件并显示我的记录当我理解发送数据时,记录响应的'xxxx'不是真的无效而且没有显示空白的json,如'[]'),几乎所有的东西都测试,比如字符集,...(所有评论的东西) )请帮助我在下面你在Web服务和Mysql:php端和Web服务中显示我的代码:

<?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 is 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 is Integer Yes!!!" . PHP_EOL;
} else {
echo "ID is not Integer!!!" . PHP_EOL;
}

if (is_int($Email)) {
echo "Email is Integer Yes!!!" . PHP_EOL;
} else {
echo "Email is not Integer!!!" . PHP_EOL;
}

if (is_int($Mobile)) {
echo "Mobile is Integer Yes!!!" . PHP_EOL;
} else {
echo "Mobile is not Integer!!!" . PHP_EOL;
}
//////////////////////////////
if (is_string($ID)) {
echo "ID is String Yes!!!" . PHP_EOL;
} else {
echo "ID is not String!!!" . PHP_EOL;
}

if (is_string($Email)) {
echo "Email is String Yes!!!" . PHP_EOL;
} else {
echo "Email is not String!!!" . PHP_EOL;
}

if (is_string($Mobile)) {
echo "Mobile is String Yes!!!" . PHP_EOL;
} else {
echo "Mobile is 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 is good word too, and show me true query 
$sql = "CALL getRecord('$ID','$Email','$Mobile');";
if (mysqli_connect_errno()) {
echo "Failed to 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端和程序代码:

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(*) FROM persons WHERE persons.Email = Email AND persons.Mobile = Mobile);
IF CheckMe = 1 THEN
SELECT * FROM persons WHERE persons.ID = ID;
ELSE 
SELECT * FROM persons WHERE persons.ID = 'xxxx';
END IF ;
END $$
DELIMITER ;

0 个答案:

没有答案