我该如何修复php函数bool? [关闭]

I dont know what is the problem with this function:

function server_grafico_expirar($data) {
    $data = sanitize($data);
    $query = mysql_query("SELECT `data_exp` FROM `settings` WHERE `data_exp` = '$data'");
    return (mysql_result($query, 0) == 1) ? true : false;
}

This function was supposed to return true if the date('d.m.Y') equals the date in mysql.

Im using like this:

$data = date('d.m.Y');
if(server_grafico_expirar($data)){
    echo "Today, is the date!";
}

The error is:

Parse error: syntax error, unexpected T_IF in /home/mcser325/public_html/checker.php on line 35

Firstly, you must make sure that the settings table does contain a row that has the data_exp column set to todays date in the format d.m.Y.

mysql_result retrieves the contents of one cell from a MySQL result set. The cell that you are retrieving is data_exp. From your question I have assumed that data_exp is a date in the format of d.m.Y.

With that said, mysql_result($query, 0) will never be equal to 1 as it will return the date you are selecting. You could approach this in two ways, you could either check if the cell equals $data and then return true

function server_grafico_expirar($data) {
   $data = sanitize($data);
   $query = mysql_query("SELECT `data_exp` FROM `settings` WHERE `data_exp` = '$data'");
   return mysql_result($query, 0) == $data;
}

You could also check how many rows are returned. If more than zero rows are returned then you can return true.

function server_grafico_expirar($data) {
   $data = sanitize($data);
   $query = mysql_query("SELECT `data_exp` FROM `settings` WHERE `data_exp` = '$data'");
   return mysql_num_rows($query) > 0;
}

Please note that the mysql extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.

Aside from any other potential errors, what your PHP parser is saying is that there is a syntax error. It's not in what you showed us at least, but make sure that you've closed every corresponding curly brackets ({ }) and they are properly matched up and that all lines end with a semicolon (;).

I'd suggest indenting properly to find the error more easily.