I am trying to create a voting system in PHP. Apart from creating a standard table with 'USER' and 'PASS' as fields to contain login information, I created another table with fields : 'USER' and 'CHECK' where 'CHECK' is a binary INT with a default value of "0". But when a student votes, the 'CHECK' field is updated to '1'.
I have the login script designed such that it first checks for a record in 'USER' and 'PASS', then checks for another record in the 'USER' and 'CHECK' table for a default value of "0" to allow voting. If its "1", it redirects to an 'AlreadyVoted.htm' page.
<?php
session_start();
$_SESSION['StudentID']=$_POST['UserID'];
include 'db_conneck.php';
$studentid=mysql_real_escape_string($_POST['UserID']);
$userpass=mysql_real_escape_string($_POST['LogPass']);
$sql="SELECT * FROM user_login WHERE studentid='$studentid' and password='$userpass'";
$sql1="SELECT * FROM check_login WHERE studentid='$studentid' and check='0'";
$sql2="SELECT * FROM check_login WHERE studentid='$studentid' and check='1'";
$result=mysql_query($sql);
$result1=mysql_query($sql1);
$result2=mysql_query($sql2);
$count=mysql_num_rows($result);
$count1=mysql_num_rows($result1);
$count2=mysql_num_rows($result2);
if ($count==1 and $count1==1){
header ("location:FirstVote.php");
}
else if ($count==1 and $count2==1){
header ("location:AlreadyVoted.html");
}
else {
echo "Information Not On Database";
}
exit()
?>
However I get this error
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\xampp\FirstVotePage\LoginCombo.php on line 13
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\xampp\FirstVotePage\LoginCombo.php on line 14 Information Not On Database