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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:42:23+00:00 2026-06-10T04:42:23+00:00

I can’t see the: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

  • 0

I can’t see the:

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

Can anyone help as my code looks spot on:

<?php
//retreive questions from database and put into question box

$query = "SELECT `QuestionId`, `Question`, `Opt1`, `Opt2`, `Opt3`, `Opt4`,`Answer` FROM `pf_questions`";

$question = mysql_query($query);

while($row = mysql_fetch_array($question)){

    $id         = $row['QuestionId'];
    $question   = $row['Question'];
    $opt1       = $row['Opt1'];
    $opt2       = $row['Opt2'];
    $opt3       = $row['Opt3'];
    $opt4       = $row['Opt4'];
    $answer     = $row["Answer"];

?>
<div id="ContainerQuestion">
    <span class="Question">Question <?php echo $id; ?>. <?php echo $question; ?></span>

        <p><input type=radio name='q<?php echo $id; ?>' value="<?php echo $opt1; ?>"> <?php echo $opt1; ?> </p>
        <p><input type=radio name='q<?php echo $id; ?>' value="<?php echo $opt2; ?>"> <?php echo $opt2; ?> </p>
        <p><input type=radio name='q<?php echo $id; ?>' value="<?php echo $opt3; ?>"> <?php echo $opt3; ?> </p>

        <p><input type=radio name='q<?php echo $id; ?>' value="<?php echo $opt4; ?>"> <?php echo $opt4; ?> </p>


</div>
<?php
}

Have tried the mysql_error() and nothing gets outputted so i’m assuming my query is correct?

many 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-10T04:42:25+00:00Added an answer on June 10, 2026 at 4:42 am

    You don’t seem to make the mysql connection anywhere in your code at all. Are you sure there is a valid connection to the database?

    Secondly, it would be rather advisable to swap over to PDO which is much safer, shinier and better than the old mysql_* functions.

    Having said that, you need to use something like the following to connect using the oder functions:

    mysql_connect("localhost", "mysql_user", "mysql_password") or
        die("Could not connect: " . mysql_error());
    mysql_select_db("mydb");
    

    Edit:

    Could you add the following section of code and let me know the output?

    $query = "SELECT `QuestionId`, `Question`, `Opt1`, `Opt2`, `Opt3`, `Opt4`,`Answer` FROM `pf_questions`";
    $question = mysql_query($query);
    $num_rows = mysql_num_rows($question);
    echo "$num_rows Rows<br>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help me with an excel formula that groups related rows and creates
Can anyone help, how to retrieve exactly 2nd row from the table in oracle?
Can i get the source code for a WAMP stack installer somewhere? Any help
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can anyone help me trying to find out why this doesn't work. The brushes
Can anyone please help, or give me a nudge on how to move forward
Can anyone please help me with the alternative to ScalaToolsSnapshots resolver currently listed in
Can anyone give me an example of how to return the following json simply
Can anybody help me? What should be the datatype for this type -07:00:00 of
Can you guys help me understand a concept real quick, I'm having trouble understanding

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.