[英]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.