简体   繁体   English

1054-“ where子句”中的未知列“ apa_calda”

[英]1054 - Unknown column 'apa_calda' in 'where clause'

I keep getting the error 1054 - Unknown column 'apa_calda' in 'where clause' in MySQL. 我不断收到错误1054 - Unknown column 'apa_calda' in 'where clause' MySQL 1054 - Unknown column 'apa_calda' in 'where clause'中的1054 - Unknown column 'apa_calda' in 'where clause' Here is the query: 这是查询:

SELECT user_id FROM `detalii_contor` WHERE tip_contor=apa_calda

I want to use this query in a PHP file but it doesn't give any results. 我想在PHP文件中使用此查询,但未给出任何结果。 So I tried to write it in the SQL command prompt. 因此,我尝试在SQL命令提示符下编写它。 Here is what I tried in the PHP file: 这是我在PHP文件中尝试过的方法:

$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'";

even without "" or without '' . 即使没有""或没有''

I wanted to get $contor from a form. 我想从表格中获得$contor I also tried with $_POST['util'] and {$_POST['util']} . 我还尝试了$_POST['util']{$_POST['util']} I've also tried to set $contor the value I need, but no result. 我还尝试将$contor设置$contor所需的值,但没有结果。

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'");

mysql meaning that apa_calda is a column name. mysql表示apa_calda是列名。 if it's a value, quote it like 如果是一个值,请像这样引用

SELECT user_id FROM detalii_contor WHERE tip_contor='apa_calda'

about $_POST['util'] - try to use $_REQUEST - http://php.net/manual/en/reserved.variables.request.php 关于$ _POST ['util']-尝试使用$ _REQUEST- http: //php.net/manual/zh/reserved.variables.request.php

may be you set $contor in function? 您可能在功能中设置了$ contor吗? then you should use directive "global" 那么您应该使用指令“ global”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 1054 where子句中的未知列? - 1054 Unknown column in where clause? “ where子句”中的未知列“ x” [1054] - Unknown column 'x' in 'where clause' [1054] PDO#1054“ where”子句中的未知列“ n” - PDO #1054 Unknown column 'n' in 'where clause 找不到列:1054“ where子句”中的未知列“ id”-Laravel - Column not found: 1054 Unknown column 'id' in 'where clause' - Laravel 未找到列:1054“ where子句”中的未知列“ id” - Column not found: 1054 Unknown column 'id' in 'where clause' updateOrCreate()给出未找到的列:1054“ where子句”中的未知列“ 0” - updateOrCreate() gives Column not found: 1054 Unknown column '0' in 'where clause' 未找到列:1054 'where 子句'中的未知列'id' Laravel 5.6 - Column not found: 1054 Unknown column 'id' in 'where clause' Laravel 5.6 如何修复错误号:1054“ where子句”中的未知列“ Array” - How to fix Error Number: 1054 Unknown column 'Array' in 'where clause' 错误:SQLSTATE[42S22]:未找到列:1054 'where 子句'中的未知列 '0' - ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'where clause' SQLSTATE [42S22]:找不到列:1054 'where 子句'中的未知列'Users.email' - SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Users.email' in 'where clause'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM