mysql_query():3不是有效的MySQL-Link资源,无法更新数据:用户''@ localhost'拒绝访问数据库错误[重复]

This question already has an answer here:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php 
 $con = mysql_connect("localhost","root","");
    if(!$con)
    {
    die("cannot connect" . mysql_error());
    }
    mysql_select_db("library",$con);

    $sql = "SELECT Renewal_Date FROM ilist ";
    $mydata = mysql_query($sql,$con);
    $result_array = array();


  while($record = mysql_fetch_array($mydata)){

  echo"<tr>";
  echo "<td>" . $record['Renewal_Date'] . "</td>";
  echo "</tr>";
  $todayDate = date('m/d/Y');
  $date1 = new DateTime($todayDate);
  $date2 = new DateTime($record['Renewal_Date']);
  if($date2 < $date1)
    {
  $interval = $date1->diff($date2); //  I assume renewal date should be greater , so it must be $date2->diff($date1);
  echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d."        days ";
  echo"<p>";
 $extradays=$interval->m;
if($extradays==1)
{
    $eday=1;
    }else if($extradays==3){
        $eday=2;
        }   else if($extradays==5){
            $eday=3;
                }   else if($extradays==7){
                    $eday=4;
                    }   else if($extradays==8){
                        $eday=5;
                        }   else if($extradays==10){
                            $eday=6;
                            }   else if($extradays==12){
                                $eday=7;
                                }
                                else{
            $eday=0;
        }

$yd= $interval->y*365*3+$interval->d*3;

    $ydm=$yd+$interval->m*30*3;
    $ydm=$ydm+($eday*3);

}
else
{
     $ydm=0;
    }
        $sql = 'UPDATE ilist
        SET Fine="$ydm"';

mysql_select_db('library');
$retval = mysql_query($sql,$con);
if(! $retval )
{
  die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully
";
mysql_close($con);//("UPDATE ilist SET Fine=$ydm");

}
?>
<body>
</body>
</html>

two errors are occuring when i compile 1)mysql_query(): 3 is not a valid MySQL-Link resource 2)Could not update data: Access denied for user ''@'localhost' to database error

All i want do is to update database in which I newly added a column called Fine . the entire fine column is zero initially, the rest of the columns in ilist table are filled earlier from php and html form. Do I need to add a textbox for fine also in form? but i am not going to enter anything from form into fine textbox.

</div>

when i compile

PHP is interpreted

Could not update data: Access denied for user ''@'localhost' to database error

Self-explanatory. Invalid MySQL details. Check those with the MySQL Config

Deprecated