返回语句的语法错误

编程入门 行业动态 更新时间:2024-10-21 09:12:00
本文介绍了返回语句的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在做一个简单的网站,却遇到了这个错误:

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.

更多推荐

返回语句的语法错误

本文发布于:2023-11-03 15:34:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555465.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语句   语法错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!