的URL從Swift中的遠程數據庫更新記錄我想傳遞url中的整數參數來更新遠程數據庫中的記錄的字段,但出現錯誤。如何做到這一點?我的PHP的作品,但不是如果從Swift調用。你如何執行一個PHP文件來更新Swift中的數據庫記錄?使用帶參數
下面是服務器上更新記錄的php。我如何從Swift應用程序運行這個?從網上我做這種方式,它運行(IdTask是唯一的):
http://.../updateonetasktocompleted.php?x=2
<?php
$host = "localhost"; //database host server
$db = "dbname"; //database name
$user = "dbuser"; //database user
$pass = "passwd"; //password
$connection = mysql_connect($host, $user, $pass);
//Check to see if we can connect to the server
if(!$connection)
{
die("Database server connection failed.");
}
else
{
//Attempt to select the database
$dbconnect = mysql_select_db("dbname", $connection);
//Check to see if we could select the database
if(!$dbconnect)
{
die("Unable to connect to the specified database!");
}
else
{
$idtask_selected = $_GET['x'];
$query = "UPDATE ProtocolSets_Protocols SET `ProtocolSets_Protocols`.`Completed`='Yes' WHERE `ProtocolSets_Protocols`.`IdTask`= $idtask_selected";
$resultset = mysql_query($query, $connection);
echo "Successfully added ";
echo $query;
}
}
?>
多德顯示您的代碼在這裏。還有你得到什麼錯誤。 – SHAZ 2015-03-30 18:49:58