我看到了与我的问题类似的帖子,但是由于某种奇怪的原因,他的解决方案对我不起作用,这使我的年龄比奥巴马快.
iOS代码
Nsstring *strURL = [Nsstring stringWithFormat:@"http://www.example.com/PHPfile.PHP?dishname=%@&description=%@",textfieldTwo.text, textfieldTwo.text];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
Nsstring *strResults = [[Nsstring alloc]initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", strResults);
<?PHP
$servername="localhost";
$username="admin";
$password="admin";
$dbname="dbname";
$conn=MysqLi_connect($servername, $username, $password, $dbname);
if (!$conn)
{
die("Connection Failed: " . MysqLi_connect_error());
}
$dishname=$_POST['dishname'];
$description=$_POST['description'];
echo "Name : " . $dishname;
//echo "Mail : ". $mail;
$sql="insert into RecipeFeed (dishName, Description) values ('" . $dishname . "', '" . $description . "')";
$result=MysqLi_query($conn, $sql);
?>
数据库映像
我不知道为什么我遇到这个问题.任何帮助将不胜感激,谢谢!
解决方法:
您正在通过GET传递参数.所以你必须改变
$dishname = $_POST['dishname'];
$description = $_POST['description'];
至
$dishname = $_GET['dishname'];
$description = $_GET['description'];
在您的PHP脚本中.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。