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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:43:44+00:00 2026-05-25T11:43:44+00:00

When I run the following php code the while loop only runs once even

  • 0

When I run the following php code the while loop only runs once even if there is more than one row in practice_calendar_times.

$sql = "
    SELECT * FROM practice_calendar_times;
    ";
$result = mysql_query($sql, $con);
if($result){
    while($practice = mysql_fetch_array($result)){
        //... Prints data from the row + more ...
    }
}

On the web page I get a printed warning message: “Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /rmounts/vol0-nas/yorkweb/webs/fencing/MyWebSite/homecontent.php on line 113”.

Line 113 is the while loop. I looked it up and apparently this is generally caused by a syntax error with the mysql query. However this is not the case here; the mysql is correctly pulling the first row from the database and the while loop is running once. If I replace the while with an if it does not complain and prints out one row. I also tried deleting all but one row in practice_calendar_times, but still get the warning message. However when I delete all of the rows it does not print a warning.

Any ideas on how to get the while loop to iterate through the table and stop complaining?

  • 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-25T11:43:45+00:00Added an answer on May 25, 2026 at 11:43 am

    Are you altering the value of $result in the body of the while loop? Why not change it to an if and var_dump($result) after it to make sure it’s still a resource?

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

Sidebar

Related Questions

If I run the following PHP code: apc_compile_file(relative/path/to/file); will it invalidate the in-memory cache
I have code in php such as the following: while($r = mysql_fetch_array($q)) { //
Trying to run the following command in php to run powershell command... the following
I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec(/home/johnboy/ffmpeg/ffmpeg
When I run the following, PowerShell hangs waiting for the dialog to close, even
When I run the following code to test copying a directory, I get a
I'd like to be able to run a line of PHP code on the
I have the following PHP code that uses cURL: $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,http://area51.stackexchange.com/users/flair/31.json); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
I've run into a problem whilst converting some C code to PHP, specifically in
I have the following php code, which has been snipped for brevity. I am

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.