Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:17:35+00:00 2026-05-30T17:17:35+00:00

EDIT I am now getting an error: Warning: mysql_num_rows() expects parameter 1 to be

  • 0

EDIT

I am now getting an error:

  Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /home/jahedhus/public_html/system/vote.php on line 126

My php code is as follows:

    <?php 

$id = $_GET['election'];

$result = mysql_query("SELECT * FROM votes WHERE election_id = '$id' AND ni = '". $_SESSION['ni']."'" )

or die(mysql_error());

if (mysql_num_rows($result) == 0) {

   $sql="SELECT * FROM elections WHERE status = 'in_progress' AND election_id = '$id'";

$result1=mysql_query($sql);

$options="";
$party2="";
$party3="";

while ($row=mysql_fetch_array($result1)) {

    echo "<tr>";
    echo "<td><h5>" . $row['name_of_election']. "</h5><hr></td>";
    echo "</td>";


    $idd=$row["party1"];
    $thing=$row["party1"];
    $options.="<OPTION VALUE=\"$idd\">".$thing;

    $idd=$row["party2"];
    $thing=$row["party2"];
    $party2.="<OPTION VALUE=\"$idd\">".$thing; 

    $idd=$row["party3"];
    $thing=$row["party3"];
    $party3.="<OPTION VALUE=\"$idd\">".$thing;

}
}
?>

<?php if (mysql_num_rows($result1) == 0) : ?>
  <form action="votecasted.php?election=<?php echo $id; ?>" method="post">

    <span id="spryselect1">
    <label for="vote">Vote</label>&nbsp;
    <select size=1" name="vote" id="vote">
        <option selected="selected">Select Your Desired Party</option>
        <?=$options?>
        <?=$party2?>
        <?=$party3?>
</select>
    <span class="selectRequiredMsg">*</span></span><br />

<br />    <input name="" type="submit" value="Vote" />
  </form>

<?php else : ?>
    You cannot post vote anymore.
<?php endif; ?>

Line 126 is where it says:

<?php if (mysql_num_rows($result1) == 0) : ?>

Its weird becuase once a user has voted, it shows the error message whereby if the user hasnt voted, it says ‘You cannot post vote anymore’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:17:36+00:00Added an answer on May 30, 2026 at 5:17 pm

    If I correctly understand the question, you just have to check $result to be different from false. I’d suggest you to use the following syntax for embedded PHP:

    <?php if ($result) : ?>
        <form></form>
    <?php else : ?>
        Something else
    <?php endif; ?>
    

    In your case, with some more SQL Injection checks:

    <?php 
    $id = mysql_real_escape_string($_GET['election']);
    $ni = mysql_real_escape_string($_SESSION['ni']);
    $votes = mysql_query("SELECT * FROM votes WHERE election_id = '$id' AND ni = '$ni'" )
    or die(mysql_error());
    
    if (mysql_num_rows($votes) == 0) {
        $sql = "SELECT * FROM elections WHERE status = 'in_progress' AND election_id = '$id'";
        $elections = mysql_query($sql);
    
        $options="";
        $party2="";
        $party3="";
        while ($row = mysql_fetch_array($elections)) {
            echo "<tr>";
            echo "<td><h5>" . $row['name_of_election']. "</h5><hr></td>";
            echo "</td>";
            $idd=$row["party1"];
            $thing=$row["party1"];
            $options.="<OPTION VALUE=\"$idd\">".$thing;
    
            $idd=$row["party2"];
            $thing=$row["party2"];
            $party2.="<OPTION VALUE=\"$idd\">".$thing; 
    
            $idd=$row["party3"];
            $thing=$row["party3"];
            $party3.="<OPTION VALUE=\"$idd\">".$thing;
        }
    }
    ?>
    
    <?php if (mysql_num_rows($votes) == 0) : ?>
        <form action="votecasted.php?election=<?=$id?>" method="post">
            <span id="spryselect1">
            <label for="vote">Vote</label>&nbsp;
            <select size="1" name="vote" id="vote">
                <option selected="selected">Select Your Desired Party</option>
                <?=$options?>
                <?=$party2?>
                <?=$party3?>
            </select>
            <span class="selectRequiredMsg">*</span></span><br />
            <br />
            <input name="" type="submit" value="Vote" />
      </form>
    <?php else : ?>
        You cannot post vote anymore.
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This compiles without error or warning, how is this possible? if (DateTime.Now == null)
I recently rebuilt my website and now I'm getting this error: Warning: mysql_result(): supplied
Edit: Warning - I now realize that the following technique is generally regarded as
I've just reorganised my code (which worked before) and am now getting an error
I am getting compiler error: cannot cast expression of type 'System.Xml.Linq.XElement to type AutomationStatusType
Issue 2. I am now getting an error in where the code is not
EDIT: now the question becomes, how do I tell Sajax to use POST instead
EDIT: Now a Major Motion Blog Post at http://messymatters.com/sealedbids The idea of rot13 is
THIRD EDIT: I now believe that this problem is due to a SOAP version
EDIT: There's now a doc page on this so this question is irrelevant, also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.