22, November 2008

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

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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 950 times)
Metal slug addict
*
Posts: 18
132 credits
Members referred : 0


« on: Oct 13, 2006, 07: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: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Oct 13, 2006, 08:38:00 PM »

replace this code to get an error:

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


Last blog : Just a better Internet portal provided by Google
Metal slug addict
*
Posts: 18
132 credits
Members referred : 0


« Reply #2 on: Oct 13, 2006, 10: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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Nov 22, 2008, 02:58:54 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!


Forum Statistics
Total Posts: 37.736
Total Topics: 7.650
Total Members: 4.396
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: thomas09

35 Guests, 4 Users online :

11 users online today:



Readers

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