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 where Student_Id=?";
$mydata = mysqli_query($sql,$con);
$result_array = array();
echo "<table border=2 >
<tr>
<th>Renewal_Date</th>
</tr>";
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);
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);
echo $ydm;
}
else
{
echo $ydm=0;
}
}
?>
<body>
</body>
</html>
the same code was working in my desktop but in laptop it is showing mysql_fetch_array() expects parameter 1 to be resource, boolean given... error in while loop. what would be the reason? i just want to fetch renewal date from database and do some calculations. logic is completely fine since it was working perfectly in my desktop, but in laptop this error is occuring, please help. `
</div>