is that correct to collect id by function

I built a little advanced import MySQL and this last didn’t work. I dont know whats the problem. studid recive empty

function getid($conf){
    $q = "select id from student where studid=$conf";
    $r = mysql_query($q);

    return $r;
}

if (strcmp($fil,$course)==0) {
     if($_FILES["file"]["size"] > 0)
     {
        $file = fopen($filename, "r");
        while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE)
        {
           $conf=$emapData[0];
            $con = getid($conf);

            $sql = "INSERT into studentsubject (`studid`, `classid`, `Dw`, 
               `Ts`,Ex, `Av`) 
            values('$con','$emapData[1]','$emapData[2]',
           '$emapData[3]','$emapData[4]','$emapData[5]')";

            //we are using mysql_query function. it returns a resource on true 
            else False on error
            $result = mysql_query( $sql, $conn );
            if(! $result )
            {
                echo "<script type=/"text/javascript/">
                          alert(/"Invalid File:Please Upload CSV File./");
                          window.location = /"../import.php/"
                      </script>";
            }
        }

For starters you are returning the recordset to $con instead of the student id:

function getid($conf){
    $q = "select id from student where studid=".$conf;
    $r = mysql_query($q);
    $x = mysql_fetch_row($r);
    return $x[0];  //field 0 of the row
}