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:
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());