MySQL错误:where子句中的未知列 [英] MySQL-Error: Unknown column in where clause
本文介绍了MySQL错误:where子句中的未知列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<div class="ui-widget">
<form method="POST">
<?php
if(isset($_POST['search'])){
$connection = mysql_connect('localhost', 'root', '1234');
mysql_select_db('hoppers');
$query = "SELECT user_name FROM users WHERE {$_POST['username']} = user_name";
$result = mysql_query($query) or die ("MySQL-Error: " . mysql_error());
$row = mysql_fetch_array($result);
if($row = TRUE){
$present = $row['user_name'];
echo $present;
}else{
echo "This User does not exist!";
}
}
?>
<label for="tags">Username: </label>
<input type="text" id="tags" name = "username">
<input type="submit" name="search" value="Suchen!">
</form>
</div>
因此,我总是收到以下错误消息: MySQL错误:'where子句'中的未知列'dompol171'.
因此,它会将我输入的用户名与"user_name"列本身进行比较.我一直很害怕...因为我不知道如何以不同的方式进行比较!
So I'm always getting the this error-message: MySQL-Error: Unknown column 'dompol171' in 'where clause'.
So it is comparing the username that I entered with the column "user_name" itself. I keep freaking out...since I have no clue how to compare it in a different way!
推荐答案
尝试使用此方法:
$username = $_POST['username'];
$query = "SELECT user_name FROM users WHERE user_name='" . $username . "'";
这篇关于MySQL错误:where子句中的未知列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文