的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