I need a help when running the index.php from internet an error displayed :-
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/ultimaz4/public_html/www-trucktradermalta-com/site/dog/index.php on line 39
This code is created from wampserver. Locally is running but in internet host the page will displayed did error.
<code>
<!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>Home</title>
<link rel="stylesheet" href="styles/screen.css" />
</head>
<body>
<div id="website">
<?
$username="ultimaz4_charab2";
$password="charab2PASS";
$database="ultimaz4_charab2";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$select = "SELECT * FROM news ORDER BY postedon DESC LIMIT 0,5";
$result=mysql_query($query);
$num=mysql_numrows($result);
//will include the code from top.php file (banner & navigation)
include('top.php');
?>
<div id="content">
<div id="contentleft">
<?
//checking if the user is an administrator
if (isset($_SESSION['superadmin']))
{
if ($_SESSION['superadmin'])
echo "<a href=\"addnews.php\">Add news</a>";
}
?>
<h2>News</h2>
<?
$i=0;
while ($i< $num)
{
echo "<div class=\"blog\" style=\"overflow: auto;\">";
echo "<h3>" . stripslashes($news['title']) . "</h3>";
echo "<small>posted on: " . date("d/m/Y H:i", strtotime($news['postedon'])) . "</small>";
echo "<p>" . stripslashes($news['body']) . "</p>";
echo "<p>" .stripslashes($news['info']) . "</p>";
echo "<div style=\"float: left; padding-left: 80px;\"><img src=\"images/" . $news['filename'] . "\" /></div>";
if (isset($_SESSION['user']) && $_SESSION['superadmin'] == true)
{
echo "<div style=\"float: right;\"><a href=\"editnews.php?id=" . $news['id'] . "\">Edit</a> | <a onclick=\"return confirm('Are you sure you want to delete this news?');\" href=\"deletenews.php?id=" . $news['id'] . "\">Delete</a></div>";
}
echo "</div>";
$i++;
}
mysql_close();
?>
</div>
<div id="contentright">
<div class="blog">
<h2>Search</h2>
<form method="post" action="search.php">
<table>
<tr>
<td>
<input type="text" name="txtSearch" />
</td>
<td>
<input type="submit" name="btnSearch" value="Search" />
</td>
</table>
</form>
</div>
<div class="blog">
<?
if (!isset($_SESSION['user']) || (isset($_SESSION['user']) && $_SESSION['user'] == false))
{
?>
<h2>Login</h2>
<form method="post" action="login.php">
<table>
<?
if (isset($_GET['e']) && $_GET['e'] == "1")
{
?>
<tr>
<td colspan="2" style="color: #FF0000; font-weight: bold">
Error: Incorrect username and password
</td>
</tr>
<?
}
?>
<tr>
<td>
Username
</td>
<td>
<input type="text" name="txtUsername" />
</td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input type="password" name="txtPassword" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="btnLogin" value="Login" />
</td>
</tr>
</table>
</form>
<br /><a href="register.php">New User?</a>
<?
}
else
{
?>
<h2>My Account</h2> <small>(<?= $_SESSION['userinfo']['username'] ?>)</small>
<br /><a href="settings.php">Settings</a><br />
<a href="user.php?id=<? echo $_SESSION['userinfo']['id']; ?>">My Profile</a><br />
<a href="logout.php">Logout</a>
<?
}
?>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
</code>
Thanks