$ result mysql_query()难度[关闭]

I am trying to pull information from my database, using an option list and choosing the row to the according selection.

table: sales

columns: year, q1, q2, q3, q4

values: 2011, 127.24, 106.54, 88.04, 120.89

When trying to return a $result query from my database. It returns two warnings:

mysql_query() expects parameter 1 to be string

mysql_error() expects parameter 1 to be resource

This is my code:

<?php

$mysqli = mysqli_connect("localhost","admin","admin","testDB");

$year= $_POST['year'];

$taryear= filter_input(INPUT_POST, 'year');
$yearsql= "SELECT year FROM sales WHERE year = '".$taryear."'";
$result= mysql_query($mysqli, $yearsql) or die(mysql_error($mysqli));


?>

<html>
<body>
    <form action = "salespie.php" method = "POST">
        <select name = "year">
            <option value = "2011">2011</option>
            <option value = "2012">2012</option>
            <option value = "2013">2013</option>
        </select>
        <input type = "submit" value = "Submit">
    </form>
</body>
</html>

I have tried to echo the $year itself, and it returns 2011.

I also echo'd $yearsql with the result of: SELECT year FROM sales WHERE year = '2011'

I don't quite understand what i'm doing wrong to get those two warnings.

Any guidance / help would be greatly appreciated!

Thanks,

As Fred mentioned in the comment, you're mixing mysql_* and mysqli_* functions.
They are not the same thing.

Given that you're passing your connection link, you probably mean to be using mysqli_query instead.

mysqli_connect uses the new object oriented mysql classes and returns a new object.

The query should work if you do

$result = $mysqli->query($yearsql);
if(!$mysqli->errno) //Check if an error occured * fixed small typo with an extra o {
   echo 'Error: '.$mysqli->error;
}

The problem is you are using mysqli objects with old(deprecated) mysql methods.

There are mysqli procedural functions for the mysqli to work. Where you use mysql_query or mysql_error replace those with mysqli_ equivalents.