本文介绍了返回语句的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一个简单的网站,却遇到了这个错误:
I'm doing this simple website, and I have run into this error:
我的功能:
<?php function user_exists($username) { $username = sanitize($username); $query = mysqli_query($connect, "SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'"); return (mysqli_result($query, === 0) 1) ? true : false; } ?>我的php错误日志:
PHP Parse error: syntax error, unexpected '===' (T_IS_IDENTICAL) in function on line 6第6行是返回行.
我了解语法错误的含义,但是我很确定'==='并不是问题.
I understand what a syntax error means, but I'm quite sure that the '===' is not the problem.
推荐答案我只是在谈论三元条件,这个答案是错误的,因为 mysqli_result()函数不存在.
Edit : I was only talking about the ternary condition and this answer is false because the mysqli_result() function doesn't exist.
我想您正在尝试这样做:
I guess you are trying to do this :
return mysqli_result($query) === 0 ? false : true;正如Marcel Korpel所说,请使用准备好的语句来避免安全漏洞.
And as Marcel Korpel said, use prepared statements to avoid security flaws.
更多推荐
返回语句的语法错误
发布评论