在'where子句'中删除未知列'int value'

时间:2013-10-27 14:29:34

标签: 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'

我在哪里做错了?感谢。

1 个答案:

答案 0 :(得分:0)

可能在查询中的$ link_id周围添加单引号

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