gpt4 book ai didi

php - 当我向数据库插入一个值时,它向数据库插入了两行

转载 作者:行者123 更新时间:2023-11-28 23:48:50 25 4
gpt4 key购买 nike

在 Android 应用程序中,我使用 Php 代码将数据插入到 sql 数据库中当我向数据库中插入一条记录时,它正在插入两条记录。这里是

PHP:

<?php
$mysql_host = "localhost";
$mysql_database = "...";
$mysql_user = "...";
$mysql_password = "...";

$con = mysql_connect($mysql_host, $mysql_user,$mysql_password,$mysql_database) || die("Error DB Connect");

$selectedDb = mysql_select_db($mysql_database)|| die("Error in opening DB");

$points = $_POST["points"];
$user = $_POST["user"];

$sql = "INSERT INTO `cusTrans`( `CID`, `Point`, `Date`, `time`,`Description`)
VALUES ($user,$points,CURRENT_DATE,CURRENT_TIME,'Claim Point')";

if (mysql_query($sql)) {
echo "OK";
} else {
echo "Fault".mysql_error();
}
?>

安卓:

httpclientCD     =  new DefaultHttpClient();
httppostCD = new HttpPost("http://.../ClaimRecord.php");
nameValuePairsCD = new ArrayList<NameValuePair>(2);
nameValuePairsCD.add(new BasicNameValuePair("user", cus_id1));
nameValuePairsCD.add(new BasicNameValuePair("points", "1"));
httppostCD.setEntity(new UrlEncodedFormEntity(nameValuePairsCD));

// Execute HTTP Post Request
responseCD = httpclientCD.execute(httppostCD);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final String response1 = httpclientCD.execute(httppostCD, responseHandler);
System.out.println("Response CusUpdatePOint : "+id+"--" + response1);

最佳答案

您能否尝试在您的 android 部分中注释掉以 ResponseCD 开头的行?抱歉,我的回答很简短,但我在用手机。

关于php - 当我向数据库插入一个值时,它向数据库插入了两行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32961866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com