28, May 2012

admin_user_update.php / Adding info / Joining tables - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: admin_user_update.php / Adding info / Joining tables
« previous next »
Pages: [1] Print

Author Topic: admin_user_update.php / Adding info / Joining tables  (Read 1556 times)
Metal slug addict
*
Posts: 18
132 credits
Members referred : 0


« on: Oct 13, 2006, 06:59:55 pm »

 Hi Olaf,

I am adding info to the admin_user_update.php page.

The goal is that when the user searches for a username to update the result will display the profile info in addition to what's already there.

I have no problem when adding fields that are in the user table. When I change the query to left join the user_profile table I get  the following error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

I suspect the problem is $this->table_name but I'm not able to change it to a value that will work.



                                                $sql = sprintf("SELECT id, login, real_name, email, access_level, active FROM %s Left Join `users_profile` ON `users_profile`.`users_id` = `users`.`id` WHERE login = '%s'", $this->table_name, trim($for_user));
      }
      else {
         $sql = sprintf("SELECT id, login, real_name, email, access_level, active FROM %s Left Join `users_profile` ON `users_profile`.`users_id` = `users`.`id`  WHERE id = %d", $this->table_name, intval($for_user));
      }
      $result = mysql_query($sql);
      if (mysql_num_rows($result) == 1) {
         $obj = mysql_fetch_object($result);
         $this->user_id = $obj->id;
         $this->user_name = $obj->login;
         $this->real_name = $obj->real_name;
         $this->old_user_email = $obj->email;
         $this->user_access_level = $obj->access_level;
         $this->activation = $obj->active;
         if ($this->user_name != $_SESSION['user']) {
            $this->user_found = true;
         } else {
            $this->user_found = false;
            $this->the_msg = "You cannot change your own data!";
         }
         mysql_free_result($result);
      } else {
         $this->the_msg = "Sorry, no login data for this name!";
      }   
   }

Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Oct 13, 2006, 07:38:00 pm »

replace this code to get an error:

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

Metal slug addict
*
Posts: 18
132 credits
Members referred : 0


« Reply #2 on: Oct 13, 2006, 09:06:46 pm »


Thanks Olaf.

That gave me the error message to answer the problem. When I joined the user_profile table it created an ambiguous column name on the 'id' column.

Regards, Jeff
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4434
Tags : mysql email Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: admin_user_update.php / Adding info / Joining tables
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 02:12:30 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.