user_profile Problem

Post here is you are having problems with any of the tutorials.
Post Reply
wizzuriz
Posts: 53
Joined: Mon Jul 25, 2011 4:22 pm

user_profile Problem

Post by wizzuriz »

Hello, I have a problem with the query in the user_profile video part 02.

This is my user.inc.php file
<?php
// fetches all of the users from the table.
function fetch_users(){
    $result = mysql_query('SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users`');

    $users = array();
    
    while(($row = mysql_fetch_assoc($result)) !== false){
      $users[] = $row;  
}

    return $users;
}

// fetches profile information for the given user.
function fetch_user_info($uid){
    $uid =(int)$uid;
    
    $sql = "select 
                `user_username` AS `username`,
                `user_firstname` AS `firstname`,
                `user_lastname` AS `lastname`,
                `user_email` AS `email`,
                `user_about` AS `about`
                `user_location`AS `location`
                `user_gender` AS `gender`
               FROM `users`
               WHERE `user_id` = {$uid}";
                
                $result = mysql_query($sql);
                
                // this is where there should be a problem. 
                return mysql_fetch_assoc($result); // line 32
}
?>
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in
/Applications/XAMPP/xamppfiles/htdocs/user_profile/core/inc/user.inc.php on line 32

I don´t´understand how it works in the video when its tested and not when I test it.

Please help me out here, I really like to move on with the videos.

best regards
Wizzuriz
User avatar
Kamal
Posts: 123
Joined: Fri May 06, 2011 10:45 am
Contact:

Re: user_profile Problem

Post by Kamal »

There's an error in your query.
Add echo mysql_error(); after mysql_query().
Post Reply