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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:05:26+00:00 2026-06-02T12:05:26+00:00

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

  • 0

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in * on line 35

if($_SERVER['REQUEST_METHOD'] =='POST'){

    $userid = $_SESSION['userid'];
    $todo = $_POST['todo'];
    $description = $_POST['description'];
    $date = $_POST['date'];
    $priority = $_POST['priority'];
    $username = $_SESSION['username'];
}   

$get_product = mysql_query("SELECT * FROM inlog WHERE userid = '".$_SESSION['userid']."' ORDER BY id DESC");

while ($row = mysql_fetch_assoc($get_product)) { // Line 35
      ?>

I would like if someone could explain me what I did wrong, Searched the web off, but couldnt solve my problem. Thats why I’m Here 🙂
///////// PROBLEM SOLVED

Next Question:
Im echoing,(instead of dieing) my wrong todo etc.. But the problem is, He still adds it in my DB. Could anyone explain what to do against it, I understand that if he doesnt die, he will still add it, but only gives an message.

I Guess there is no need to put the script in here. But if so. Ill add it.

  • 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-02T12:05:35+00:00Added an answer on June 2, 2026 at 12:05 pm

    Most likely something is empty, update your script to locate the problem:

    if($_SERVER['REQUEST_METHOD'] =='POST'){
        $userid = (int) $_SESSION['userid']; // Cast to (int) to make it safe
        if (empty($userid))
            die('Invalid User ID');
    
        $todo = $_POST['todo'];
        if (empty($todo))
            die('Invalid todo');
    
        $description = $_POST['description'];
        if (empty($description))
            die('Invalid description');
    
        $date = $_POST['date'];
        if (empty($date))
            die('Invalid date');
    
        $priority = $_POST['priority'];
        if (empty($priority))
            die('Invalid priority');
    
        $username = $_SESSION['username'];
        if (empty($todo))
            die('Invalid username');
    
        $get_product = mysql_query("SELECT * FROM inlog WHERE userid = '".$userid."' ORDER BY id DESC"); // See how I changed $_SESSION['userid'] to $userid
    }   
    

    Also make sure you are escaping your variables before you do a query with them. Just the way I casted the userid to an integer.

    About the second question:

    Next Question: Im echoing,(instead of dieing) my wrong todo etc.. But
    the problem is, He still adds it in my DB. Could anyone explain what
    to do against it, I understand that if he doesnt die, he will still
    add it, but only gives an message.

    Best solution according to me:

    if($_SERVER['REQUEST_METHOD'] =='POST'){
        $errors = array();
    
        $userid = (int) $_SESSION['userid']; // Cast to (int) to make it safe
        if (empty($userid))
            $errors[] = 'Invalid User ID'
    
        $todo = $_POST['todo'];
        if (empty($todo))
             $errors[] = 'Invalid todo';
    
        $description = $_POST['description'];
        if (empty($description))
            $errors[] = 'Invalid description';
    
        $date = $_POST['date'];
        if (empty($date))
            $errors[] = 'Invalid date';
    
        $priority = $_POST['priority'];
        if (empty($priority))
            $errors[] = 'Invalid priority';
    
        $username = $_SESSION['username'];
        if (empty($todo))
            $errors[] = 'Invalid username';
    
        // Only do the query when there are no errors    
        if (count($errors) <= 0) {
            $get_product = mysql_query("SELECT * FROM inlog WHERE userid = '".$userid."' ORDER BY id DESC"); // See how I changed $_SESSION['userid'] to $userid
        } else {
            echo implode('<br />', $errors); // or return is also a possibility
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result Warning: mysql_fetch_assoc():
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I'm getting
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I am
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result what is
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result okay so
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I have
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I tried
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I've this
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result $err =

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.