c# - 删除 'int value' 中的未知列 'where clause'

标签 c# php mysql sql sql-delete

我有一个表,其中有一个名为 link_id 的 A_I 列。当我这样运行时:

$link_id = 32;
$query1 = "DELETE FROM links WHERE link_id = $link_id";
if(!mysql_query($query1,$connection));
{
    die(mysql_error($connection));
}

它工作成功,但是当我使用 C# WebRequest 尝试此操作时:

WebRequest request = WebRequest.Create("http://www.mywebsite.com/deleteLink.php");
request.Method = "POST";
string post = "link_id=" + id //type string;
byte[] postBytes = Encoding.UTF8.GetBytes(post);
request.ContentLength = postBytes.Length;
request.ContentType = "application/x-www-form-urlencoded";
Stream dataStream = await request.GetRequestStreamAsync();
dataStream.Write(postBytes, 0, postBytes.Length);
WebResponse response = await request.GetResponseAsync();
return new StreamReader(response.GetResponseStream()).ReadToEnd();

返回:“where 子句”中的未知列“32”

我哪里做错了?谢谢。

最佳答案

也许在查询中的 $link_id 周围添加单引号

$query1 = "DELETE FROM links WHERE link_id = '$link_id'";

关于c# - 删除 'int value' 中的未知列 'where clause',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19619168/

相关文章:

c# - 无法将 COM 对象转换为类类型

c# - LinqToSQL 设计查询/担忧

php - 使用 PHP 临时将文件夹权限更改为 777

php - 从自己的 CMS 中的 wp_postmeta 提取数据

MySQL基于当前行查询行

mysql - 在 MySQL 中将 'describe' 转换为 'create table'?

c# - 使用 MySQL 通过 C# 和 JSON.Net 创建 JSON

c# - 需要验证数据契约(Contract)和数据成员

php - 操作 PHP 数组以匹配函数的数组要求并递归调用函数

mysql - 如何将存储过程添加到 AWS RDS Aurora-Serverless?