PHP - > mySQL连接错误

I'm having a connection errors trying to connect with PHP to mySQL. I'm using a video instructable, because I've been having several of these connections before, but it is outdated and I'm trying to use mysqli instead of mysql commands, but I'm winding up with nothing posting on my pages, I think because of this. Can you tell me if this would be the correct translation of it?

function user_exists($username) {

    $username = sanitize($username);

    $query = mysqli_query("SELECT COUNT('user_id') FROM 'users' WHERE 'username' = '$username'");

Sanitize is defined on another page (and included) as:

<?php
    function sanitize ($data) {
        return mysqli_real_escape_string($data);
    }
?>

Please help!

First you need connect to MySQL..is your function have that ? It is incomplete..on the screen..

example..

$link = mysqli_connect("localhost","root","","database") or die("Error " . mysqli_error($link));
$query = "SELECT `release_year` FROM film LIMIT 5" or die("Error in the consult.." . mysqli_error($link));

//execute the query.

$result = $link->query($query);