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

  • Home
  • SEARCH
  • 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 8469583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:16:07+00:00 2026-06-10T16:16:07+00:00

I have this PHP code: if ($username) { if ($news == 1) $int =

  • 0

I have this PHP code:

if ($username) {
    if ($news == 1)
        $int = "9";
    if ($news == 0)
        $int = "12";
}
else
    $int = "9";

$query = mysql_query("SELECT * FROM files WHERE active='1' ORDER BY id DESC LIMIT $int");
require ("scripts/connect.php");
$numrows = mysql_num_rows($query);

But then I get this error (Note the line starting with $numrows is line 69):

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/Site/index.php on line 69

I have tried many ways of changing the number to no avail. Please help! Thanks!

  • 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-06-10T16:16:09+00:00Added an answer on June 10, 2026 at 4:16 pm

    If your scripts/connect.php is responsible for establishing database connection, then I belive mysql_query() should be below it, not above as it is now. I also recommend using mysql_error() and always check return values for errors, as assumptions like “query is always successful” are no-no approach and will hit you badly in less expected moment.

    require ("scripts/connect.php");
    $query = mysql_query("SELECT * FROM files WHERE active='1' ORDER BY id DESC LIMIT $int");
    if( $query ) {
      $numrows = mysql_num_rows($query);
      ...
    } else {
       die( mysql_error() );
    }
    

    Please note mysql extension is deprecated. Switch to mysqli or something more sophisticated like PDO as soon as you can.

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

Sidebar

Related Questions

I have this PHP code: $query = SELECT name, COUNT(message) FROM guestbook_message WHERE name='.$req_user_info['username'].'
I have this code: $query = select id from votes where username = '$user'
I have this php code $jsonArray = array(); $sql = SELECT ID,CLIENT FROM PLD_SERVERS;
I have this PHP code to highlight the Query on search results. if (isset($_REQUEST['k'])){
I have this piece of PHP code: <?php $username=$_POST['username']; $password=$_POST['password']; if($username&&$password){ $connect=mysql_connect(localhost,root,) or die(
I have this script: <?php if ($_POST["username"]=="") { include($_SERVER['DOCUMENT_ROOT'] ."/login.inc.php"); } else { $username=$_POST["username"];
I have this code <?php session_start(); if (isset($_GET[cmd])) $cmd = $_GET[cmd]; else die(You should
I have this PHP code in a loop for every post on the admin
i have this php code and keep on getting errors upon fixing each error.
I have this php code $filename = verbs.php; // http://alylores.x10.mx/vega/verbs2.php $handle = fopen($filename, r);

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.