Jump to content

Recommended Posts

Hi Guys,

 

been at this an hour now i can't figure out what iv done, it was working earlier, the problem is only the user name and id are being returned nothing else:

 

functions.php

 

<?php
     ####################################################################################
     # clean up the sql inputs $pm_message = CleanStrings($_POST['pm_message'], 1);
     ####################################################################################

     function CleanPosts($String, $nlbr = false) {

        if (get_magic_quotes_gpc()) {
     
          $String = stripslashes($String);
     
          } 
         
        if ($nlbr) {
     
          $String = nl2br($String);
     
     }   
         
     return mysql_real_escape_string($String);
     
     } 
     ####################################################################################
     # 
     ####################################################################################
     
     function get_logged_in_users_details($member) {
     
          $query_user = "SELECT * FROM `membership` WHERE `username`='$member'";
          $result_user = mysql_query($query_user);
          $row = mysql_fetch_array($result_user);
          $user_id = $row['id'];
          $user_name = $row['username'];
          
          echo "<br /><span class=\"release\"><align=\"center\"> Hi, <a href=\"userdetails.php?id=$user_id\">$user_name</a>!</span><br /><br />";
          
          return;
     
     }
     ####################################################################################
     # 
     ####################################################################################
     
     function standard_message($heading,$text) {
     if ($heading)
     print "<br /><table class=\"main\" width=\"750\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\"><tr><td class=embedded>";
     print "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"10\"><tr><td class=\"error_msg\">\n";
     print "<b>$heading</b>  $text</td></tr></table></td></tr></table><br />";
     
     }
   
     ####################################################################################
     # 
     ####################################################################################

     function error($heading, $text) {
     
      stdmsg($heading, $text);
      
     }
?>

 

myaccount.php

 

<?php
     // the includes...//////////////////////////////////////////////////////////////////
     include("includes/db_connection.php");
     include("includes/constants.php");
     include("includes/sessions.php");
     include("includes/functions.php");
     include("includes/header.php");
     include("includes/loginnav.php");
?>
<?php
     $countries_list = array(
                       54 => 'Afganistan',
                       65 => 'Albania',
                       35 => 'Algeria',
                       68 => 'Andorra',
                       36 => 'Angola',
                       35 => 'Algeria',
                       89 => 'Antigua Barbuda',
                       20 => 'Australia',
                       37 => 'Austria',
                       82 => 'Bahamas',
                       86 => 'Bangladesh',
                       85 => 'Barbados',
                       16 => 'Belgium',
                       34 => 'Belize',
                       67 => 'Bosnia Herzegovina',
                       18 => 'Brazil',
                      104 => 'Bulgaria',
                       60 => 'Burkina Faso',
                       82 => 'Bahamas',
                        5 => 'Canada',
                       51 => 'Chile',
                        8 => 'China',
                       99 => 'Colombia',
                      102 => 'Costa Rica',
                       53 => 'Congo',
                       97 => 'Croatia',
                       52 => 'Cuba',
                       46 => 'Czech Republic',
                       10 => 'Denmark',
                       41 => 'Dominican Republic',
                      103 => 'Egypt',
                       98 => 'Estonia',
                       14 => 'Finland',
                        6 => 'France',
                        7 => 'Germany',
                       42 => 'Greece',
                       43 => 'Guatemala',
                       33 => 'Hong Kong',
                       79 => 'Honduras',
                       74 => 'Hungary',
                       62 => 'Iceland',
                       70 => 'India',
                       44 => 'Israel',
                        9 => 'Italy',
                       13 => 'Ireland',
                       31 => 'Jamaica',
                       17 => 'Japan',
                       58 => 'Kiribati',
                       87 => 'Laos',
                      101 => 'Latvia',
                      100 => 'Lebanon',
                       69 => 'Lithuania',
                       32 => 'Luxembourg',
                       40 => 'Malaysia',
                       25 => 'Mexico',
                       63 => 'Nauru',
                       15 => 'Netherlands',
                       71 => 'Netherlands Antilles',
                       21 => 'New Zealand',
                       61 => 'Nigeria',
                       96 => 'North Korea',
                       11 => 'Norway',
                       45 => 'Pakistan',
                       90 => 'Paraguay',
                       83 => 'Peru',
                       59 => 'Philippines',
                       14 => 'Poland',
                       24 => 'Portugal',
                       50 => 'Puerto Rico',
                       75 => 'Romania',
                        3 => 'Russia',
                       47 => 'Serbia',
                       48 => 'Seychelles',
                      200 => 'Scotland',
                       94 => 'Senegal',
                       26 => 'Singapore',
                       64 => 'Slovenia',
                       29 => 'South Africa',
                       30 => 'South Korea',
                       23 => 'Spain',
                        1 => 'Sweden',
                       57 => 'Switzerland',
                       49 => 'Taiwan',
                       93 => 'Thailand',
                       50 => 'Togo',
                       78 => 'Trinidad & Tobago',
                       55 => 'Turkey',
                       55 => 'Ukraine',
                       12 => 'United Kingdom',
                        2 => 'United States of America',
                       88 => 'Uruguay',
                       56 => 'Uzbekistan',
                       73 => 'Venezuela',
                       77 => 'Vietnam',
                       39 => 'Western Samoa',
                       38 => 'Yugoslavia',
                       );
                       
     ## ARRAY ###########################################################################
     $pm_array = array("Yes","No");
                       
     get_logged_in_users_details($member); 
     
     ## users info ######################################################################
     $country = $row['country'];
     $email = $row['email'];
     $signature = $row['about_me'];
     $acc_pms = $row['accept_pms'];
     $avatar = $row['avatar'];
     $user_class = $row['user_class'];
     
     echo $query_user;
     echo $user_name;
     echo $country;
     
     ####################################################################################
     if(isset($_POST['submit'])) {
     
     $avatar = $_FILES["avatar"]["name"];
     $acceptpms = $_POST['acceptpms'];
     $cur_pass = $_POST['current_password'];
     $new_pass = $_POST['new_password'];
     $new_email = $_POST['myemail'];
     $sig = $_POST['sig'];
     $updated_country = $_POST['country'];
     $uid = $_POST['id'];
     
     ## avatar code #####################################################################
     $maxwidth = "250";
 $maxheight = "250";
 $random_number = rand(000000,999999);
 $allowed_image_types = array("image/gif","image/jpg","image/x-png","image/jpeg","image/pjpeg","image/bmp");

 ## rename avatar ###################################################################
 $renamed_avatar = $random_number.".".substr($_FILES["avatar"]["name"],strtolower(strlen($_FILES["avatar"]["name"]))-3,3); 

 $avatar_restrictions = getimagesize($_FILES["avatar"]["tmp_name"]);

     if($avatar_restrictions[0] >= $maxwidth || $avatar_restrictions[1] >= $maxheight) {
  
     standard_message("Error","Sorry that avatar is bigger than <b>$maxwidth</b> x <b>$maxheight</b> !");
     include("includes/footer.php");
     exit;
    
     }
     
     ## EMPTY ###########################################################################
     if(!empty($_FILES["avatar"]["name"])) {
     
     ## validation ######################################################################
     if (!in_array($_FILES["avatar"]["type"], $allowed_image_types)) {
   
     standard_message("Error","Image is not one of the allowed types.");
     include("includes/footer.php");
     exit;
    
     } 
     
     ## delete the avatar ###############################################################
     $query_avatar = "SELECT `avatar` FROM `membership` WHERE `id`='$uid' LIMIT 1";
     $result_avatar = mysql_query($query_avatar) or die (mysql_error()); 
     $row_delete = mysql_fetch_object($result_avatar);
     $avatar_to_delete = $row_delete->avatar;
     
     unlink("avatars/".$avatar_to_delete); 
     
     $uploadpath = "avatars/"; 
     $uploadpath = $uploadpath.$renamed_avatar;
    
     if(move_uploaded_file($_FILES["avatar"]["tmp_name"], $uploadpath)) {
       
     }
     
     } // EMPTY #########################################################################
     
     ## if old and new passwords dont match ############################################# 
     if($cur_pass != $new_pass) {
     
     standard_message("Error","Your passwords don't match.");
     include("includes/footer.php");
     exit;     
     
     }    
     
     ## the update ######################################################################
     $query_update = "UPDATE `membership` SET";
     
     if(empty($cur_pass) || empty($new_pass)) {     
     
     } else {
     
     $query_update .= " `password`='$new_pass',";
      
     } 
      
     $query_update .=" `email`='$new_email',`about_me`='$sig',`country`='$updated_country',";
     
     if(empty($avatar)) {          
     
     } else {
     
     $query_update .= "`avatar`='$renamed_avatar',";
     
     }
     
     $query_update .= " `accept_pms`='$acceptpms' WHERE `id`='$uid'";
     
     $result_update = mysql_query($query_update) or die (mysql_error()); 
     
     ## ok ##############################################################################
     if($result_update) {
     
     standard_message(" ","Your settings have been updated.");
     include("includes/footer.php");
     exit;
     
     }   

     
     }
     
     ## display pref box ################################################################
     echo '<table border="1" cellspacing="0" cellpadding="10" width="400">
           <tr>
           <td class="forum_border" align="center" width="33%"><a href="logout.php"><b>Logout</b></a></td>
           <td class="forum_border" align="center" width="33%"><a href="forums.php"><b>Forums</b></a></td>
           <td class="forum_border" align="center" width="33%"><a href="inbox.php"><b>Inbox</b></a></td>
           </tr>
           <td class="forum_border" align="center" width="33%"><a href="friendslist.php"><b>Friends</b></a></td>
           <td class="forum_border" align="center" width="33%"><a href="blockslist.php"><b>Blocks</b></a></td>
           <td class="forum_border" align="center" width="33%"><a href="contactstaff.php"><b>Contact Admins</b></a></td>
           </tr>
           <tr>
           <td colspan="3">
           <form method="POST" action="" enctype="multipart/form-data" />
           <table border="1" bordercolor="#000000" cellspacing=0 cellpadding="5" width="100%">
           <tr>
           <td width="50%" class="head" align="right">Accept PMs</td><td align="left" width="50%">';
           #########################################################################
           foreach ($pm_array as $value) {
           echo '<input type="radio" name="acceptpms" id="radio_'.$value.'" value="'.$value.'" ';
           if ($value == $acc_pms) {
           echo 'checked="checked"';
           } 
           echo ' /><label for="radio_'.$value.'">'.$value.'</label>';
           } 
           #########################################################################  
     echo '</tr>
           <tr>
           <td width="50%" class="head" align="right">E-Mail</td><td align="left" width="50%"><input type="text" name="myemail" value="'.$email.'" size="30"/></td>
           </tr>
           <tr>
           <td class="head" align="right">Old Password</td><td align="left"><input type="text" name="current_password" size="30"/></td>
           </tr>
           <tr>
           <td class="head" align="right">New Password</td><td align="left"><input type="password" name="new_password" size="30"/></td>
           </tr>
           <tr>
           <td class="head" align="right">Signature</td><td align="left"><textarea name="sig" rows="10" cols="35" value="'.$signature.'"/>'.$signature.'</textarea><br /><span class="details">Displayed On Your public Page. May Contain <a href="codes.php" target="_new">BB Codes</a>.</td>
           </tr>
           <tr>
           <td class="head" align="right">Your Country</td><td align="left"><select name="country">';       
           #########################################################################
           foreach ($countries_list as $key => $value) {
           $select = ($key == $country) ? 'SELECTED' : '';
           echo "<option value='$key' $select> $value</option>";
           }
           #########################################################################       
     echo '</select>
           </td>
           </tr>
           <tr>
           <td class="head" align="right">Selected Country</td><td align="left">';
           $query3 = "SELECT * FROM `countries` WHERE `id`='$country'";
           $result3 = mysql_query($query3);
           $row = mysql_fetch_array($result3);           
           $flag_pic = $row['flagpic']; 
           ## display the flag ##########################################################          
           echo '<img src="flags/'.$flag_pic.'">';           
     echo '</td>
           </tr>
           <tr>
           <td class="head" align="right">Upload Avatar</td><td align="left"><input type="file" name="avatar" /></td>
           </tr>
           <tr>
           <td class="head" align="right">Current Avatar</td><td align="left">';
           if(empty($avatar)) {
           
           echo "<img src=\"images/default_avatar.gif\" />";  
           
           } else {
           
           echo "<img src=\"avatars/$avatar\" />";
           
           } 
     echo '</td>
           </tr>
           <tr>
           <td align="center" colspan="2"><input type="submit" name="submit" value="Submit Changes!" style=\'height: 25px\'> <input type="reset" value="Reset Changes!" style=\'height: 25px\'> <input type="hidden" name="id" value="'.$id.'"></td>
           </tr>
           </table>
           </td>
           </tr>
           </table>
           </form><br />';
         
           ## admin #####################################################################
           if(($user_class) == 'Site Administrator') {
           ## echo the admin panel ######################################################
           echo '<table border="1" cellspacing="0" cellpadding="10" width="400">
                 <tr>
                 <td class="forum_border" colspan="2" align="center" width="99%" class="details">Admin Panel</td>
                 </tr>
                 <tr>
                 <td colspan="2">
                 <table border="1" bordercolor="#000000" cellspacing=0 cellpadding="5" width="100%">
                 <tr>
                 <td width="50%" class="head" align="left">Mass PMs</td><td align="left"><a href="masspm.php"><img src="images/mass_pm.bmp" border="0"></a></td>
                 </tr>
                 <tr>
                 <td width="50%" class="head" align="left">Mass Emails</td><td align="left"><a href="massemail.php"><img src="images/mass_email.bmp" border="0"></a></td>
                 </tr>
                 <tr>
                 <td width="50%" class="head" align="left">Edit Users</td><td align="left"><a href="masteredit.php"><img src="images/edit_users.bmp" border="0"></a></td>
                 </tr>
                 <tr>
                 <td width="50%" class="head" align="left">Purge NZBs</td><td align="left"><a href="siteclean.php"><img src="images/delete_nzbs.bmp" border="0"></a></td>
                 </tr>
                 <tr>
                 <td width="50%" class="head" align="left">Announcements</td><td align="left"><a href="announcement.php"><img src="images/announcements.bmp" border="0"></a></td>
                 </tr>
                 <tr>
                 <td width="50%" class="head" align="left">Forum Management</td><td align="left"><a href="forummanagement.php"><img src="images/forum_management.bmp" border="0"></a></td>
                 </tr>
                 </table>
                 </td>';
           echo '</table><br />';
           
           }
?>
<?php
     // include the footer...////////////////////////////////////////////////////////////
     include("includes/footer.php");
?>

 

none of these:

 

     $country = $row['country'];
     $email = $row['email'];
     $signature = $row['about_me'];
     $acc_pms = $row['accept_pms'];
     $avatar = $row['avatar'];
     $user_class = $row['user_class'];

 

are returning anything eventhough they were earlier, iv only been working with the functions file i didnt even touch the myaccoun.php one

 

can anyone see whats went wrong

 

cheers guys

 

Graham

 

 

Link to comment
https://forums.phpfreaks.com/topic/65725-solved-script-not-working-after-update/
Share on other sites

     $country = $row['country'];
     $email = $row['email'];
     $signature = $row['about_me'];
     $acc_pms = $row['accept_pms'];
     $avatar = $row['avatar'];
     $user_class = $row['user_class'];

 

are outside the function..

 

try this

get_logged_in_users_details($member); 

to

$row = get_logged_in_users_details($member); 

 

 

     ####################################################################################
     
     function get_logged_in_users_details($member) {
     
          $query_user = "SELECT * FROM `membership` WHERE `username`='$member'";
          $result_user = mysql_query($query_user);
          $row = mysql_fetch_array($result_user);
          $user_id = $row['id'];
          $user_name = $row['username'];
          
          echo "<br /><span class=\"release\"><align=\"center\"> Hi, <a href=\"userdetails.php?id=$user_id\">$user_name</a>!</span><br /><br />";
          
          return;
     
     }
     ####################################################################################

 

to

 

     ####################################################################################
     
     function get_logged_in_users_details($member) {
     
          $query_user = "SELECT * FROM `membership` WHERE `username`='$member'";
          $result_user = mysql_query($query_user);
          $row = mysql_fetch_array($result_user);
          $user_id = $row['id'];
          $user_name = $row['username'];
          
          echo "<br /><span class=\"release\"><align=\"center\"> Hi, <a href=\"userdetails.php?id=$user_id\">$user_name</a>!</span><br /><br />";
          
          return $row;
     
     }
     ####################################################################################

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.