Greetings sirs/maams,
I’m having difficulties in running my mini login page online on a web host.
Whenever I run this on my own computer using AMPP 1.7.3, I don’t receive any errors or whatsoever but when it’s online, errors arise with regards to:
ERROR:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/merptv/public_html/research/library/login.php on line 31
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/merptv/public_html/research/library/login.php on line 36
I’m really confused right now and I really can’t understand what’s wrong…
I need your help in identifying what’s wrong and on what to do to make things right…
Please and thank you maam/sirs
<?php $server = "localhost"; $username = "ndrew_root"; $password = "12345"; $database = "ndrew_library"; ?>
<?php session_start(); ?> Login Verification <?php
include(‘functions.php’);
include(‘globals.php’);
$con = mysql_connect($server, $username, $password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($database, $con);
if($_POST)
{
$userlogged = $_POST['username'];
$passlogged = $_POST['password'];
@$_SESSION['username'] = "$userlogged";
$query = "select * from tb_admin where admin_ac = '$userlogged' && admin_pass = '$passlogged' ";
$A = mysql_query($query);
$AA = mysql_num_rows($A);
@$_SESSION['username'] = "$userlogged";
$query = "select * from tb_users where student_no = '$userlogged' && student_pass = '$passlogged' ";
$B = mysql_query($query);
$BB = mysql_num_rows($B);
if((empty($_POST['username'])) && (empty($_POST['password'])))
{
$username1 = FALSE;
$password1 = FALSE;
echo "<br><br><br><br><br><br><br><br><br><br><br>";
echo '<center><font color="#a80000" face = tahoma size=2><b>ERROR: Please enter your USERNAME and PASSWORD.</b></font></center>';
echo '<meta http-equiv=Refresh content=2;url=index.php>';
}
elseif(empty($_POST['username']))
{
$username1 = FALSE;
$password1 = TRUE;
echo "<br><br><br><br><br><br><br><br><br><br><br>";
echo '<body><center><font color="#a80000" face = tahoma size=2><b>ERROR: Please enter your USERNAME.</font></center>';
echo '<meta http-equiv=Refresh content=2;url=index.php>';
}
elseif(empty($_POST['password']))
{
$username1 = FALSE;
$password1 = FALSE;
echo "<br><br><br><br><br><br><br><br><br><br><br>";
echo '<center><font color="#a80000" face = tahoma size=2><b>ERROR: Please enter your PASSWORD.</font></center>';
echo '<meta http-equiv=Refresh content=2;url=index.php>';
}
else
{
if ($AA==1)
{
while ($AA = mysql_fetch_array($A)) {
@$_SESSION = trim($AA);
@$_SESSION['priv'] = "admin";
@$_SESSION['nick'] = $AA['admin_name'];
echo "<br><br><br><br><br><br><br><br><center><font size = 3 face = tahoma><b>Welcome</font></center><br><center><font color = #a80000 face = tahoma size = 4>{$AA['admin_name']}" . "</center>";
echo '<meta http-equiv=Refresh content=2;url=main_admin.php>';
}
}
elseif ($BB==1)
{
while ($BB = mysql_fetch_array($B)) {
@$_SESSION = trim($BB);
@$_SESSION['priv'] = "user";
@$_SESSION['nick'] = $BB['student_name'];
echo "<br><br><br><br><br><br><br><br><center><font size = 3 face = tahoma><b>Welcome</font></center><br><center><font color = #a80000 face = tahoma size = 4>{$BB['student_name']}" . "</center>";
echo '<meta http-equiv=Refresh content=2;url=main_user.php>';
}
}
else
{
echo "<br><br><br><br><br><br><br><br><br><br><br>";
echo '<center><font color="#a80000" face = tahoma size=2><b><br>ERROR: Invalid USERNAME and PASSWORD.</font></center>';
echo '<meta http-equiv=Refresh content=2;url=index.php>';
}
}
}
mysql_close();
?>