Warning: mysql_connect():
No connection could be made because the target machine actively refused it. inD:\xampp\htdocs\ex\ctop.php
on line 22 Could not connect: No connection could be made because the target machine actively refused it.
Code
<html>
<head>
<title></title>
<style type="text/css">
body{background-image:url(img/11.jpg);
background-size: 100% 100%;}
table{font-size:20pt;
color: Black;
text-align: center;
font-weight:bold;}
th{color: BC8F8F;}
</style>
</head>
<body>
<?php
$dbhost = 'localhost';
$dbuser = 'corn';
$dbpass = 'pword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT Distinct i.Title,i.Singer,i.Mname FROM items i, vote v
where i.Title=v.Title
group by v.Title
order by sum(v.rating) Desc';
mysql_select_db('test_db');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
echo" <center>";
echo "<h2>Based on ratings given by users!!</h2>";
echo "<br/><br/><br/><br/><br/><br/>";
echo "<table border=1>";
echo" <tr>";
echo"<th>Title</th>";
echo"<th>Movie</th>";
echo"<th>Singer</th>";
echo" </tr>";
while($row = mysql_fetch_array($retval)) {
echo "<tr> <td>{$row['Title']} </td>".
"<td>{$row['Mname']} </td>".
"<td> {$row['Singer']}</td>
</tr>";
}
echo "</table>";
echo "</center>";
mysql_close($conn);
?>
</body>
</html>
I have already executed this php program. But sometimes I get this warning, so I tried reinstalling MySQL then I got output. Now again same warning I'm getting, how to completely overcome this problem?