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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:24:17+00:00 2026-06-02T00:24:17+00:00

I am trying to retrieve 7 columns from my Pages table, however it comes

  • 0

I am trying to retrieve 7 columns from my Pages table, however it comes up with this error: Wrong parameter count for mysql_fetch_assoc()

I must be using the wrong function, which would be the correct one to use?

Here is the code:

<?php
$query="SELECT * FROM Pages";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>

<?php
$array = array();
$i = 0;
while ($i < $num) {
$f1 =  mysql_fetch_assoc($result,$i,"Page","URL","Description","Bounce_Rate",
                         "Avg_Time_On_Page","Page_Views","Click_Rate");
$array[] = $f1;
$i++;
}
echo json_encode($array);
?>
  • 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-02T00:24:18+00:00Added an answer on June 2, 2026 at 12:24 am

    You run mysql_fetch_assoc() on the result of the query:

    $result = mysql_query( "SELECT foo, bar FROM fooTable" );
    while ( $row = mysql_fetch_assoc( $result ) ) {
      echo $row['foo']; // $row['bar'] also available
    }
    

    Note the signature of this function in the documentation:

    array mysql_fetch_assoc ( resource $result )

    This means the function returns an array as its result. And it accepts only one parameter, which must be a resource. A resource is that which is returned from mysql_query. We know this by checking the signature of that method as well:

    resource mysql_query ( string $query [, resource $link_identifier = NULL ] )

    This method returns a resource (which can be used with mysql_fetch_assoc), and accepts at least one parameter (the query), with the optional second parameter of a link identifier (that is, your connection to a database).

    When in doubt, check the documentation. Also mysql_numrows should be mysql_num_rows.

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

Sidebar

Related Questions

I'm trying to retrieve columns based on their corresponding key. Select * from diamond
I'm trying to retrieve records from table by knowing the date in column contains
I'm trying to retrieve a variable from an extended class. This is how my
I'm trying to retrieve two columns from the DB with iBatis. I want to
I am trying to retrieve a column from another related table, and display that
I am trying to retrieve fields from a table in a SQLite database. I've
I am trying retrieve user name from the code through graph api, the below
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I'm trying to retrieve the SubItem in my ListView from another thread, but I
I am trying to retrieve the correct value from an ArrayList of objects (.NET

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.