Results 1 to 2 of 2

Thread: [RESOLVED] Problem with mysql_fetch_assoc

  1. #1

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Resolved [RESOLVED] Problem with mysql_fetch_assoc

    This is the error i am getting

    Code:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Student Planner\account.php on line 40
    I am using the example from php.net, i am unsure as to why the application is crashing?

    PHP Code:
    if($_POST['email']==""||$_POST['password']=="")
            {
                
    $berror=1;
                
    $message.="<p>Please complete all fields</p>";
            }
            else
            {
                
    $sql="SELECT * FROM student_users WHERE id = '" $_SESSION['userid'] . "' LIMIT 1";
                
                
    $result mysql_query($sql);
                
                if (!
    $result
                {
                    
    $berror=1;
                    
    $message.="<p>Could not successfully run query ($sql) from DB: " mysql_error() . "</p>";
                }
                else
                {
                    if(
    mysql_num_rows($result)==0
                    {
                        
    $berror=1;
                        
    $message.="<p>No rows found, nothing to print so am exiting</p>";
                    }
                    else
                    {
                        while (
    $row mysql_fetch_assoc($result))  // THIS IS LINE 40
                        
    {
                            if(
    $row['password']==md5($_POST['password']))
                            {
                                
    $sql="UPDATE student_users Set email = '" $_POST['email'] . "' WHERE id = '" $_SESSION['userid'] . "'";
                                
                                
    $result mysql_query($sql);

                                if (!
    $result
                                {
                                    
    $berror=1;
                                    
    $message.="<p>Could not successfully run query ($sql) from DB: " mysql_error() . "</p>";
                                }
                            }
                            else
                            {
                                
    $berror=1;
                                
    $message.="<p>Incorrect password</p>";
                            }
                        }
                    }
                }
            } 
    Thats the code I am using
    Last edited by penagate; May 4th, 2007 at 09:07 PM. Reason: [highlight=php]=>[php]

  2. #2

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Problem with mysql_fetch_assoc

    Resolved, i used two $results

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width