1

Well, basically I am working on a register and login tutorial on youtube. Which is using the old version of PHP, and I have attempted to update the code, however I get this error:

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;
}
?>
1
  • 2
    return mysqli_affected_rows($con), 0, 'user_id'; Huuu? What should that be ? <-
    – Rizier123
    Commented Mar 24, 2015 at 19:30

1 Answer 1

2

Line 23 is this one: return mysqli_affected_rows($con), 0, 'user_id';

Must be: return mysqli_affected_rows($con) ? 0 : 'user_id'; if this what you meant.

Cannot return multiple values in PHP.