|
|
|
ปัญหา การทำ Login Form และ Update MySQL Data ผ่าน Web Service ด้วย PHP (NuSoap) |
|
|
|
|
|
|
|
Error ตัวนี้เป็นแค่ Warning ครับ ใส่ @ ข้างหน้าก็ไม่แสดงแล้วครับ ส่วนที่มัน ไม่แสดง Result ผมว่าตัว Web Services มันทำงานได้ปกติไหม๊ครับ
|
|
|
|
|
Date :
2015-05-22 09:41:33 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมลองเอา
<?php
$objConnect = mysql_connect("localhost","root","password") or die(mysql_error());
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer WHERE 1 AND CustomerID = 'C001' ";
$objQuery = mysql_query($strSQL) or die (mysql_error());
$intNumField = mysql_num_fields($objQuery);
$resultArray = array();
while($obResult = mysql_fetch_array($objQuery))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
print_r ($resultArray);
mysql_close($objConnect);
?>
มาทดลองแยกก็ทำงานปกติได้ค่า
Array ( [0] => Array ( [CustomerID] => C001 [Username] => win [Password] => win001 [Name] => Win Weerachai [Email] => [email protected] [CountryCode] => TH [Budget] => 1000000 [Used] => 600000 ) )
ซึ่งถูกต้อง
เลยไม่รู้ว่าส่วนในที่ผิดพลาดทำให้ ไม่ return ค่ากลับมา ช่วยชี้แนะด้วยครับ
|
|
|
|
|
Date :
2015-05-22 10:13:03 |
By :
surasaky |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอความช่วยเหลือ ชี้แนะหน่อยครับ
|
|
|
|
|
Date :
2015-05-22 20:10:57 |
By :
surasaky |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเอาโค๊ดที่แสดงผลผิด มาลงดีกว่าครับ
และ mysq_num_field เขาไม่ใช้กันแล้ว จะใช้ กรณีที่ ไม่มี result ส่งมาเท่านั้นครับ
ส่วนถ้ามี result ส่งมา
Code (PHP)
$resultArray=array();
$rs=$db->query( $sql );
while( $ro=$rs->fetch_assoc()){
$resultArray[]=$ro;
}
print_r($resultArray);
|
|
|
|
|
Date :
2015-05-22 20:35:24 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
งั้นก็ตาสดวกครับ ลาละครับ
|
|
|
|
|
Date :
2015-05-22 20:58:25 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
require_once("lib/nusoap.php");
//Create a new soap server
$server = new soap_server();
//Define our namespace
$namespace = "http://localhost/nusoap/WebServiceServer_Show.php";
@$server->wsdl->schemaTargetNamespace = $namespace;
//Configure our WSDL
$server->configureWSDL("getCustomer");
//Add ComplexType
$server->wsdl->addComplexType(
'DataList',
'complexType',
'struct',
'all',
'',
array(
'CustomerID' => array('name' => 'CustomerID', 'type' => 'xsd:string'),
'Username' => array('name' => 'Username', 'type' => 'xsd:string'),
'Password' => array('name' => 'Password', 'type' => 'xsd:string'),
'Name' => array('name' => 'Name', 'type' => 'xsd:string'),
'Email' => array('name' => 'Email', 'type' => 'xsd:string'),
'CountryCode' => array('name' => 'CountryCode', 'type' => 'xsd:string'),
'Budget' => array('name' => 'Budget', 'type' => 'xsd:float'),
'Used' => array('name' => 'Used', 'type' => 'xsd:float')
)
);
//Add ComplexType
$server->wsdl->addComplexType(
'DataListResult',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:DataList[]')
),
'tns:DataList'
);
//Register our method and argument parameters
$varname = array('strCustomerID' => "xsd:string");
// Register service and method
$server->register('resultCustomer', // method name
$varname, // input parameters
array ('return' => 'tns:DataListResult'));
function resultCustomer($strCustomerID)
{
$objConnect = mysql_connect("localhost","root","password") or die(mysql_error());
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer WHERE 1 AND CustomerID = '".$strCustomerID."' ";
$objQuery = mysql_query($strSQL) or die (mysql_error());
$intNumField = mysql_num_fields($objQuery);
$resultArray = array();
while($obResult = mysql_fetch_array($objQuery))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
mysql_close($objConnect);
return $resultArray;
}
// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
?>
code ทั้งหมดครับ
|
ประวัติการแก้ไข 2015-05-22 21:13:07 2015-05-22 21:13:44
|
|
|
|
Date :
2015-05-22 21:12:21 |
By :
surasaky |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|