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 1095863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:11:34+00:00 2026-05-17T00:11:34+00:00

The result is always 1: $sql = ‘SELECT COUNT(Vote) FROM ‘ . $table; $res

  • 0

The result is always 1:

$sql = 'SELECT COUNT(Vote) FROM ' . $table;
$res = mysql_query($sql, $conn);
$vote_total = mysql_num_rows($res);

I ran the $sql query in phpMyAdmin and it returns 3, so the query is not the problem. $vote_total is initialized globally to 0, so that 1 is coming from somewhere. What other information do I need to provide to make helping me easier?

Thanks,
Ryan

  • 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-17T00:11:35+00:00Added an answer on May 17, 2026 at 12:11 am

    mysql_num_rows returns the number of selected rows and not the fields of a certain row. Use mysql_fetch_row to fetch the row you have selected with your query:

    $sql = 'SELECT COUNT(Vote) FROM ' . $table;
    $res = mysql_query($sql, $conn);
    $row = mysql_fetch_row($res);
    $vote_total = $row[0];
    

    You could also use mysql_result to fetch a row and get a certain field:

    $vote_total = mysql_result($res, 0, 0);
    

    This fetches the first row (zero based) and returns the first field (zero based).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the SQL query: SELECT ISNULL(t.column1, t.column2) as [result] FROM t I need
I have this query in my sql if (select count(*) from sys.columns where object_id
Will the following two SQL statements always produce the same result set? 1. SELECT
First off, here's my SQL query: SELECT research_cost, tech_name, (SELECT research_cost FROM technologies WHERE
$result = $db_con->query(SELECT SQL_CALC_FOUND_ROWS * FROM users LIMIT 0,10); $count_result = $db_con->query(SELECT FOUND_ROWS() as
I have a table created with PHP from an Sql Database that successfully displays
I am trying to obtain a random row from the result of an SQL
When I run an XQuery query in PL-SQL using SELECT XQUERY('...' RETURNING CONTENT) FROM
I came across the following SQL statement: SELECT A.NAME FROM THE_TABLE A WHERE A.NAME
We are facing one problem with DownloadStringCompleted method always returning same result in windows

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.