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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:46:17+00:00 2026-05-26T11:46:17+00:00

I have some pretty simple code: $result = mysql_query( SELECT max(id) as id, ip,

  • 0

I have some pretty simple code:

$result = mysql_query("
SELECT  max(id) as id, ip, max(entry), COUNT(ip) AS count 
FROM table_name
GROUP BY ip
ORDER BY max(id) asc
");

$i = 0;

$num_rows = mysql_num_rows($result);

echo $num_rows;


while($row = mysql_fetch_row($result)) {
    $id = $row['id'];
    $entry = $row['entry'];
    $ip = $row['ip'];
    $count = $row['count'];
    $i++;
?>



<tr width="100%" align="center">
    <td><?php echo $i; ?></td>
    <td><?php echo $id; ?></td>
    <td><?php echo $entry; ?></td>
    <td><?php echo $ip; ?></td>
    <td><?php echo $count; ?></td>
    <td>
    <form style="display:inline;" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <input type="hidden" value="<?php echo $ip; ?>" name="ip" />
        <input type="hidden" value="<?php echo $id; ?>" name="id" />
        <input type="submit" value="Ban IP" name="submit" />
    </form>
    </td>
</tr>

<?php
}

The problem is that when I run it, I get:

Notice: Undefined index: id
Notice: Undefined index: entry
Notice: Undefined index: ip
Notice: Undefined index: count

But as far as I can see, I have defined the indexes in the SQL statement, any help would be appreciated. It selects the data using the column names id, ip, entry and creates the index “count” for the count of ip’s, so why does it say that it hasn’t been defined?

  • 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-26T11:46:17+00:00Added an answer on May 26, 2026 at 11:46 am

    To get the result row as an associative array you should use mysql_fetch_assoc instead of mysql_fetch_row.

    Also you haven’t defined entrydespite your claim that you have. Change this:

    SELECT max(id) as id, ip, max(entry), COUNT(ip) AS count 
    

    To this:

    SELECT max(id) as id, ip, max(entry) AS entry, COUNT(ip) AS count 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some pretty simple code that reads lines from a network stream that
I have a pretty simple UIScrollView defined inside Interface Builder. I've pasted in some
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out
Pretty much what the title says really. We have some code that is .NET
I have a pretty simple question, but for some reason I am drawing a
I have added a simple .js file to my page that has some pretty
I have some simple OpenGL ES code in C++ that I've run on a
I have some pretty basic code to capture a still image using AVFoundation. AVCaptureDeviceInput
I have a pretty simple C program that does some cryptographic calculations using only
I'm looking at building a Rails application which will have some pretty large tables

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.