Home > Backend Development > PHP Tutorial > php判断语句

php判断语句

WBOY
Release: 2016-06-23 14:09:47
Original
1145 people have browsed it

有一句条件不会写。
$username=trim($_POST['username']);
$password=trim(&_POST['pass']);
//declare the SQL statement that will query the database
$query = "select top 6 * from WEB_VIEW  where DNBH='$username' order by SFMonth desc ";

//execute the SQL query and return records
$result = mssql_query($query) or die ("查询数据失败: ".mysql_error());

$numRows = mssql_num_rows($result); 
$nRow=mssql_fetch_array($result);
if (empty($numRows)&&$password substr(row[3], -4) ) {echo "

没有查到数据哦,请正确输入用户名和密码。谢谢!

";}
else {
  //输出结果
}

empty($numRows)&&$password  substr(row[1].lenth-3,4) 我的意思是 ,当查询结果为空 或者 用户输入的密码和数据库中的row[1] 最后 4个字符对比,如果不对,就输出错误提示,让用户再次输入用户名和密码 .  
运行时提示出错,Parse error: syntax error, unexpected '[' in D:\WWW\test.php


回复讨论(解决方案)

substr(row[3], -4)
应写为
substr($nRow[3], -4)

$numRows = mssql_num_rows($result); 
$nRow=mssql_fetch_array($result);
if (empty($numRows) || $password  substr(nRow[3],-4)) {echo "

没有查到数据哦,请正确输入用户名和密码。谢谢!

";}

我已经改过来了

你怎么总是要漏掉“$”

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template