kumarsivarajan / rmh-roomreservation-maker

Automatically exported from code.google.com/p/rmh-roomreservation-maker
0 stars 0 forks source link

function retrieve_UserProfile_SW($profileId) #46

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Retrieve socialWorkerProfileID from a reservation 
2. Use the function retrieve_UserProfile_SW($profileId) based on that 
ID 

What is the expected output? What do you see instead?
Expected to return a social worker's profile, instead I'm being told 
that no object is returned 

Please use labels and text to provide additional information.
I think the problem is that we aren't specifying between UserProfileID 
and socialWorkerProfileID. For Mary Tove, it retrieves the ID "1", 
which is her socialWorkerProfileID. Her UserProfileID is different, 
which is "2". It looks to me like the function is trying to return a 
Social Worker who's ID is "1", but the UserProfileID of "1" belongs to 
Frank, who is actually an RMH staff member, not a social worker, and 
therefore the function returns nothing. I can try to re-explain that 
if you don't know what I mean.

Original issue reported on code.google.com by kaylahay...@gmail.com on 25 Apr 2012 at 9:37

GoogleCodeExporter commented 8 years ago
Also, the function returns an array, when it should only get one social worker 
if it is based on a unique ID

Original comment by kaylahay...@gmail.com on 25 Apr 2012 at 9:50

GoogleCodeExporter commented 8 years ago
Locally, I changed the function to:

function retrieve_UserProfile_SW($userProfileId)
{
        connect();
    $query="SELECT U.UserProfileID, U.UserCategory, S.SocialWorkerProfileID,S.Title,S.FirstName, S.LastName,U.UsernameID, U.Password, U.UserEmail, S.Phone, S.HospitalAffiliation,S.EmailNotification
            FROM userprofile U JOIN socialworkerprofile S
            ON U.UserProfileID= S.UserProfileID
            WHERE U.UserCategory='Social Worker' AND S.SocialWorkerProfileID=\"".$userProfileId."\"";

       $result = mysql_query ($query);

    if (mysql_num_rows($result) <1)
    {
       mysql_close();
        return false;

    }

    $result_row = mysql_fetch_assoc($result);
    $user = new UserProfile($result_row['UserCategory'], $result_row['UserProfileID'], $result_row['UsernameID'],$result_row['UserEmail'],
    $result_row['Password'],'null','null', 'null',
    'null', 'null', $result_row['SocialWorkerProfileID'], $result_row['Title'],
    $result_row['FirstName'], $result_row['LastName'], $result_row['HospitalAffiliation'], $result_row['Phone'], 
    $result_row['EmailNotification']);

    mysql_close();
    return $user;  
}

and that returned the correct information

Original comment by kaylahay...@gmail.com on 25 Apr 2012 at 9:53

GoogleCodeExporter commented 8 years ago
Yeah. If you want to use his code, you have to specify the first element.
I was trying to figure out why it worked for me and not you. :)

Original comment by alisa.mo...@stjohns.edu on 25 Apr 2012 at 9:58

GoogleCodeExporter commented 8 years ago
I don't think it should return an array though, since it has the function 
return false if there is more than one row anyways, right?

Original comment by kaylahay...@gmail.com on 25 Apr 2012 at 10:01

GoogleCodeExporter commented 8 years ago
I'm also having a problem with this function.
I just ran the new DB script. When try to run:

$SW = retrieve_UserProfile_SW(2);
echo $SW;

I get:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in 
C:\Program Files\wamp\www\rmh-reservation-maker\database\dbUserProfile.php on 
line 393

Original comment by alisa.mo...@stjohns.edu on 26 Apr 2012 at 12:44

GoogleCodeExporter commented 8 years ago
You can ignore Comment 5. For some reason I had no tables in my DB.

Original comment by alisa.mo...@stjohns.edu on 26 Apr 2012 at 3:02

GoogleCodeExporter commented 8 years ago
This warning message gets generated when a query fails, but no error message is 
recorded. Don't ignore this message! Instead, make sure you handle query errors 
properly

    $result = mysql_query ($query)or die(mysql_error());

Original comment by bkmackellar on 10 May 2012 at 9:07

GoogleCodeExporter commented 8 years ago

Original comment by bkmackellar on 2 Sep 2012 at 7:09