1054-'where子句'中的未知列'apa_calda' [英] 1054 - Unknown column 'apa_calda' in 'where clause'

查看:83
本文介绍了1054-'where子句'中的未知列'apa_calda'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在MySQL中收到错误1054 - Unknown column 'apa_calda' in 'where clause'.这是查询:

I keep getting the error 1054 - Unknown column 'apa_calda' in 'where clause' in MySQL. Here is the query:

SELECT user_id FROM `detalii_contor` WHERE tip_contor=apa_calda

我想在PHP文件中使用此查询,但没有任何结果.因此,我尝试在SQL命令提示符下编写它. 这是我在PHP文件中尝试过的内容:

I want to use this query in a PHP file but it doesn't give any results. So I tried to write it in the SQL command prompt. Here is what I tried in the PHP file:

$Q = "SELECT id_contor, den_contor FROM detalii_contor WHERE tip_contor='".$contor."'";

$Q = "SELECT id_contor, den_contor FROM detalii_contor WHERE tip_contor='$contor'";

即使没有""或没有''.

我想从表单中获取$contor.我还尝试了$_POST['util']{$_POST['util']}.我还尝试设置$contor我需要的值,但没有结果.

I wanted to get $contor from a form. I also tried with $_POST['util'] and {$_POST['util']}. I've also tried to set $contor the value I need, but no result.

推荐答案

字段值应该用引号引起来.
SELECT user_id FROM detalii_contor WHERE tip_contor='apa_calda'

Field value should be in quotes.
SELECT user_id FROM detalii_contor WHERE tip_contor='apa_calda'

顺便说一句,您应该始终逃避来自用户的一切.例如,

By the way, you should always escape everything that comes from users. For example,

$mysqli = new mysqli("host", "user", "password", "db");
$contor = $mysqli->real_escape_string($_POST['util'] );
$result = $mysqli->query(SELECT id_contor, den_contor FROM detalii_contor WHERE tip_contor='$contor'");

$mysqli = new mysqli("host", "user", "password", "db");
$contor = $mysqli->real_escape_string($_POST['util'] );
$result = $mysqli->query(SELECT id_contor, den_contor FROM detalii_contor WHERE tip_contor='$contor'");

这篇关于1054-'where子句'中的未知列'apa_calda'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆