gpt4 book ai didi

php - PHP解析错误: syntax error, unexpected ',' in

转载 作者:行者123 更新时间:2023-12-03 08:21:57 25 4
gpt4 key购买 nike

好吧,基本上我正在YouTube上注册和登录教程。它正在使用旧版本的PHP,并且我尝试更新代码,但是出现此错误:

Parse error: syntax error, unexpected ',' in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\Forum\forum\core\functions\users.php on line 23



users.php
<?php
function user_exists($username, $con) {
$data = $username;
$username = sanitize($data, $con);
$username = $data;
mysqli_query($con, "SELECT `user_id` FROM `users` WHERE `username` = '$username'");
return(mysqli_affected_rows($con) == 1) ? true : false;
}

function user_active($username, $con) {
$data = $username;
$username = sanitize($data, $con);
$username = $data;
mysqli_query($con, "SELECT `user_id` FROM `users` WHERE `username` = '$username' AND `active` = 1");
return(mysqli_affected_rows($con) == 1) ? true : false;
}

function user_id_from_username ($username, $con) {
$data = $username;
$username = sanitize($data, $con);
$username = $data;
mysqli_query($con, "SELECT `user_id` FROM `users` WHERE `username` = '$username'");
return mysqli_affected_rows($con), 0, 'user_id';
}

function login($username, $password, $con) {
$user_id = user_id_from_username($username, $con);
$data = $username;
$username = sanitize($data, $con);
$username = $data;
$password = md5($password);
return (mysqli_affected_rows(mysqli_query($con, "SELECT `user_id` FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false;
}
?>

最佳答案

23是这个:return mysqli_affected_rows($con), 0, 'user_id';
必须是:return mysqli_affected_rows($con) ? 0 : 'user_id';(如果这是您的意思)。

无法在PHP中返回多个值。

关于php - PHP解析错误: syntax error, unexpected ',' in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29241208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com