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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:18:38+00:00 2026-06-13T09:18:38+00:00

I am getting this error when I execute my page: Warning: mysql_fetch_assoc() : supplied

  • 0

I am getting this error when I execute my page:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource …

I have tried running the SQL directory on phpMyAdmin and it runs fine.

Here is the full code:

<?php

$connect_error = 'Sorry, we have connection problems.';

mysql_connect('localhost','user','password') or die($connect_error);
mysql_select_db('mydb') or die($connect_error);



$result = mysql_query("SELECT * FROM tbl_main ORDER BY id desc limit 1");
 $rows = array();


   while($r = mysql_fetch_assoc($result)) {  //ERROR POINTS HERE
     $rows['id'][] = $r;
   } 

 print json_encode($rows);



?>

Why I’m I getting this error?

  • 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-13T09:18:40+00:00Added an answer on June 13, 2026 at 9:18 am

    If mysql_query returns FALSE, then you’ll get an error. It can return false if there is a problem with you SQL, or there is a problem with your database connection.

    Call mysql_error() to find out more about the error that occured.

    Also, you should really be using PDO or MySQLi with PHP now.

    <?php
    
    $connect_error = 'Sorry, we have connection problems.';
    
    $link = mysql_connect('localhost','user','password') or die($connect_error);
    mysql_select_db('mydb', $link) or die($connect_error);
    
    $result = mysql_query("SELECT * FROM tbl_main ORDER BY id desc limit 1", $link);
    if ($result) {
        $rows = array();
    
        while($r = mysql_fetch_assoc($result)) {  //ERROR POINTS HERE
            $rows['id'][] = $r;
        } 
    
        print json_encode($rows);
    } else {
        print mysql_error($link);
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am getting this error failed to execute request because the app-domain could not
I keep getting this error when I tried to execute this query, although I
Okay, I'm getting this error when I try to execute this procedure. The thing
I am getting an error when I execute this query in php: SELECT hit.timestamp,
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
I am getting this error when trying to execute the SSIS package. [Flat File
When I load my page I'm getting this error: Fatal error: Can't use function
I keep getting this error when I try to commit a group of executed
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Getting this error when try to add an item to my repositories/context: Collection has

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.