You are using the old
mysql syntax with the new
mysqli extension (note the letter 'i'). The PHP
mysqli extension offers two types of interfaces: Procedural and object-oriented. See
PHP: Dual procedural and object-oriented interface - Manual[
^] on how to convert from
mysql to
mysqli.
The converted code should look like (I have commented your existing code and changed it to be the old mysql syntax by removing the 'i'):
$link = mysqli_connect('host', 'user', 'password', 'database');
if (mysqli_connect_error()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($result = mysqli_query($link, "SELECT DISTINCT type FROM coffee")) {
mysqli_free_result($result);
}
mysqli_close($link);
See also the example code provided on the PHP manual pages like
PHP: mysqli::query - Manual[
^].