PHP Error: Function Name Must Be String

majestyc

New Member
Messages
26
Reaction score
1
Points
1
Fatal error: Function name must be a string in /home/............ on line 4
Code:
<?php
function user_exists($username) {
    $username = sanitize($username);
    $query = $mysql_query ("SELECT COUNT('user_id') FROM 'majestyc_users' WHERE 'username' = '$username'");
    return (mysql_result($query, 0) == 1) ? true : false;
};
?>

I can't figure out why this is wrong.....can I please get some help? I've also tried the function name variation "userExists".
 

majestyc

New Member
Messages
26
Reaction score
1
Points
1
Ok, I've figured out the problem and it wasn't with the "user_exists" it was where I put $mysql_query() on line 4. I've fixed it by putting just mysql_query() without the "$"

I also had to replace the '' marks with `` and remove the `` marks from WHERE `username` = '$username' to get it to work.

Here is the new code for it:

Code:
<?php
function user_exists($username) {
    $username = sanitize($username);
    $query = mysql_query("SELECT COUNT(`user_id`) FROM `majestyc_users` WHERE username = '$username'");
    return (mysql_result($query, 0) == 1) ? true : false;
};
?>
 
Last edited:
Top